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>
57#define MAX6690_INT_TEMP 0x0
58#define MAX6690_EXT_TEMP 0x1
59#define MAX6690_RSL_STATUS 0x2
60#define MAX6690_EEXT_TEMP 0x10
61#define MAX6690_IEXT_TEMP 0x11
62#define MAX6690_TEMP_MASK 0xe0
111 uint8_t busy[1], rsl;
140 device_printf(
dev,
"iicbus read failed\n");
143 pause(
"max6690_read", hz);
150 const char *name, *compatible;
153 name = ofw_bus_get_name(
dev);
154 compatible = ofw_bus_get_compat(
dev);
159 if (strcmp(name,
"temp-monitor") != 0 ||
160 strcmp(compatible,
"max6690") != 0)
163 sc = device_get_softc(
dev);
167 device_set_desc(
dev,
"Temp-Monitor MAX6690");
183 int i = 0, j,
len = 0, prop_len, prev_len = 0;
185 sc = device_get_softc(
dev);
187 child = ofw_bus_get_node(
dev);
190 prop_len = OF_getprop(child,
"hwsensor-location", location,
192 while (
len < prop_len) {
195 prev_len = strlen(location +
len) + 1;
203 prop_len = OF_getprop(child,
"hwsensor-id",
id,
sizeof(
id));
204 for (j = 0; j < i; j++)
208 prop_len = OF_getprop(child,
"hwsensor-zone",
id,
sizeof(
id));
209 for (j = 0; j < i; j++)
213 for (j = 0; j < i; j++) {
239 sc = device_get_softc(
dev);
252 if (config_intrhook_establish(&sc->
enum_hook) != 0)
262 struct sysctl_oid *oid, *sensroot_oid;
263 struct sysctl_ctx_list *ctx;
264 char sysctl_desc[40], sysctl_name[32];
267 device_t
dev = (device_t)xdev;
269 sc = device_get_softc(
dev);
279 device_printf(
dev,
"WARNING: No MAX6690 sensors detected!\n");
282 M_MAX6690, M_WAITOK | M_ZERO);
284 ctx = device_get_sysctl_ctx(
dev);
285 sensroot_oid = SYSCTL_ADD_NODE(ctx,
286 SYSCTL_CHILDREN(device_get_sysctl_tree(
dev)), OID_AUTO,
"sensor",
287 CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"MAX6690 Sensor Information");
301 if (isspace(sysctl_name[j]))
302 sysctl_name[j] =
'_';
308 oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(sensroot_oid),
309 OID_AUTO, sysctl_name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
310 "Sensor Information");
312 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
"temp",
313 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
320 device_printf(
dev,
"Sensors\n");
322 device_printf(
dev,
"Location : %s ID: %d\n",
328 config_intrhook_disestablish(&sc->
enum_hook);
334 uint8_t reg_int = 0, reg_ext = 0;
336 uint8_t fraction = 0;
341 sc = device_get_softc(sens->
dev);
344 if ((sens->
id % 2) == 0) {
367 temp = (integer * 10) + (fraction >> 5) * 10 / 8;
369 return (temp + ZERO_C_TO_K);
382 sc = device_get_softc(
dev);
389 error = sysctl_handle_int(oidp, &temp, 0, req);
int iicbus_transfer(device_t bus, struct iic_msg *msgs, uint32_t nmsgs)
static int max6690_sensor_sysctl(SYSCTL_HANDLER_ARGS)
DRIVER_MODULE(max6690, iicbus, max6690_driver, max6690_devclass, 0, 0)
static devclass_t max6690_devclass
static int max6690_attach(device_t)
static int max6690_read(device_t dev, uint32_t addr, uint8_t reg, uint8_t *data)
static driver_t max6690_driver
static int max6690_fill_sensor_prop(device_t dev)
#define MAX6690_IEXT_TEMP
#define MAX6690_RSL_STATUS
static void max6690_start(void *xdev)
static MALLOC_DEFINE(M_MAX6690, "max6690", "Temp-Monitor MAX6690")
#define MAX6690_EEXT_TEMP
static int max6690_probe(device_t)
#define MAX6690_TEMP_MASK
static int max6690_sensor_read(struct max6690_sensor *sens)
static device_method_t max6690_methods[]
struct intr_config_hook enum_hook
struct max6690_sensor * sc_sensors