38#include <sys/kernel.h>
39#include <sys/module.h>
40#include <sys/malloc.h>
44#include <machine/bus.h>
46#include <dev/extres/regulator/regulator.h>
47#include <dev/fdt/fdt_pinctrl.h>
50#include <dev/ofw/ofw_bus.h>
51#include <dev/ofw/ofw_bus_subr.h>
58 {
"active-semi,act8846", 1},
62#define LOCK(_sc) sx_xlock(&(_sc)->lock)
63#define UNLOCK(_sc) sx_xunlock(&(_sc)->lock)
64#define LOCK_INIT(_sc) sx_init(&(_sc)->lock, "act8846")
65#define LOCK_DESTROY(_sc) sx_destroy(&(_sc)->lock);
66#define ASSERT_LOCKED(_sc) sx_assert(&(_sc)->lock, SA_XLOCKED);
67#define ASSERT_UNLOCKED(_sc) sx_assert(&(_sc)->lock, SA_UNLOCKED);
89 device_printf(sc->
dev,
90 "Error when reading reg 0x%02X, rv: %d\n", reg, rv);
113 device_printf(sc->
dev,
114 "Error when reading reg 0x%02X, rv: %d\n", reg, rv);
137 device_printf(sc->
dev,
138 "Error when writing reg 0x%02X, rv: %d\n", reg, rv);
160 device_printf(sc->
dev,
161 "Error when writing reg 0x%02X, rv: %d\n", reg, rv);
191 if (!ofw_bus_status_okay(
dev))
197 device_set_desc(
dev,
"ACT8846 PMIC");
198 return (BUS_PROBE_DEFAULT);
208 sc = device_get_softc(
dev);
211 node = ofw_bus_get_node(sc->
dev);
220 return (bus_generic_attach(
dev));
232 sc = device_get_softc(
dev);
235 return (bus_generic_detach(
dev));
254 NULL, NULL, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST);
static devclass_t act8846_devclass
int act8846_read_buf(struct act8846_softc *sc, uint8_t reg, uint8_t *buf, size_t size)
int act8846_write(struct act8846_softc *sc, uint8_t reg, uint8_t val)
EARLY_DRIVER_MODULE(act8846_pmic, iicbus, act8846_driver, act8846_devclass, NULL, NULL, BUS_PASS_INTERRUPT+BUS_PASS_ORDER_LAST)
static device_method_t act8846_methods[]
static int act8846_probe(device_t dev)
MODULE_DEPEND(act8846_pmic, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER)
int act8846_write_buf(struct act8846_softc *sc, uint8_t reg, uint8_t *buf, size_t size)
int act8846_modify(struct act8846_softc *sc, uint8_t reg, uint8_t clear, uint8_t set)
static DEFINE_CLASS_0(act8846_pmu, act8846_driver, act8846_methods, sizeof(struct act8846_softc))
IICBUS_FDT_PNP_INFO(compat_data)
static struct ofw_compat_data compat_data[]
static int act8846_detach(device_t dev)
MODULE_VERSION(act8846_pmic, 1)
int act8846_read(struct act8846_softc *sc, uint8_t reg, uint8_t *val)
#define LOCK_DESTROY(_sc)
static int act8846_attach(device_t dev)
int act8846_regulator_attach(struct act8846_softc *sc, phandle_t node)
int act8846_regulator_map(device_t dev, phandle_t xref, int ncells, pcell_t *cells, int *num)
int iicbus_transfer_excl(device_t dev, struct iic_msg *msgs, uint32_t nmsgs, int how)