32#include "opt_platform.h"
36#include <sys/kernel.h>
37#include <sys/module.h>
38#include <sys/sysctl.h>
41#include <machine/bus.h>
47#include <dev/ofw/ofw_bus.h>
48#include <dev/ofw/ofw_bus_subr.h>
54#define REG_LUX_HIGH 0x03
55#define REG_LUX_LOW 0x04
63static const struct ofw_compat_data
compat_data[] = {
64 {
"maxim,max44009",
true },
75 uint8_t reghi, reglo, valhi, vallo;
78 sc = device_get_softc(
dev);
103 val = ((valhi & 0x0f) << 4) | (vallo & 0x0f);
104 val <<= (valhi & 0xf0) >> 4;
117 if (req->oldptr != NULL) {
124 error = sysctl_handle_int(oidp, &
val, 0, req);
134 if (!ofw_bus_status_okay(
dev))
137 rc = BUS_PROBE_GENERIC;
140 rc = BUS_PROBE_NOWILDCARD;
141 device_set_desc(
dev,
"MAX44009 light intensity sensor");
149 struct sysctl_ctx_list *ctx;
150 struct sysctl_oid *tree_node;
151 struct sysctl_oid_list *tree;
153 sc = device_get_softc(
dev);
157 ctx = device_get_sysctl_ctx(
dev);
158 tree_node = device_get_sysctl_tree(
dev);
159 tree = SYSCTL_CHILDREN(tree_node);
161 SYSCTL_ADD_PROC(ctx, tree, OID_AUTO,
"illuminance",
162 CTLTYPE_INT | CTLFLAG_RD,
dev, 0,
static ds13_compat_data compat_data[]
int iicbus_transfer_excl(device_t dev, struct iic_msg *msgs, uint32_t nmsgs, int how)
MODULE_VERSION(max44009, 1)
MODULE_DEPEND(max44009, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER)
static int max44009_get_reading(device_t dev, u_int *reading)
static int max44009_attach(device_t dev)
static device_method_t max44009_methods[]
static devclass_t max44009_devclass
static int max44009_detach(device_t dev)
IICBUS_FDT_PNP_INFO(compat_data)
static int max44009_probe(device_t dev)
static driver_t max44009_driver
DRIVER_MODULE(max44009, iicbus, max44009_driver, max44009_devclass, 0, 0)
static int max44009_lux_sysctl(SYSCTL_HANDLER_ARGS)