Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c expose pmic reset functionality



details:   https://anonhg.NetBSD.org/src/rev/bdb5b9a30fae
branches:  trunk
changeset: 811902:bdb5b9a30fae
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Nov 21 12:19:47 2015 +0000

description:
expose pmic reset functionality

diffstat:

 sys/dev/i2c/as3722.c |  21 +++++++++++++++++++--
 sys/dev/i2c/as3722.h |   3 ++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diffs (62 lines):

diff -r c5819adfc295 -r bdb5b9a30fae sys/dev/i2c/as3722.c
--- a/sys/dev/i2c/as3722.c      Sat Nov 21 12:11:56 2015 +0000
+++ b/sys/dev/i2c/as3722.c      Sat Nov 21 12:19:47 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: as3722.c,v 1.2 2015/11/21 10:56:40 jmcneill Exp $ */
+/* $NetBSD: as3722.c,v 1.3 2015/11/21 12:19:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.2 2015/11/21 10:56:40 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: as3722.c,v 1.3 2015/11/21 12:19:47 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -53,6 +53,7 @@
 
 #define AS3722_RESET_CTRL_REG          0x36
 #define AS3722_RESET_CTRL_POWER_OFF    __BIT(1)
+#define AS3722_RESET_CTRL_FORCE_RESET  __BIT(0)
 
 #define AS3722_WATCHDOG_CTRL_REG       0x38
 #define AS3722_WATCHDOG_CTRL_MODE      __BITS(2,1)
@@ -251,3 +252,19 @@
 
        return error;
 }
+
+int
+as3722_reboot(device_t dev)
+{
+       struct as3722_softc * const sc = device_private(dev);
+       int error;
+
+       const int flags = I2C_F_POLL;
+
+       iic_acquire_bus(sc->sc_i2c, flags);
+       error = as3722_write(sc, AS3722_RESET_CTRL_REG,
+           AS3722_RESET_CTRL_FORCE_RESET, flags);
+       iic_release_bus(sc->sc_i2c, flags);
+
+       return error;
+}
diff -r c5819adfc295 -r bdb5b9a30fae sys/dev/i2c/as3722.h
--- a/sys/dev/i2c/as3722.h      Sat Nov 21 12:11:56 2015 +0000
+++ b/sys/dev/i2c/as3722.h      Sat Nov 21 12:19:47 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: as3722.h,v 1.1 2015/11/11 12:35:22 jmcneill Exp $ */
+/* $NetBSD: as3722.h,v 1.2 2015/11/21 12:19:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -30,5 +30,6 @@
 #define _DEV_I2C_AS3722_H
 
 int    as3722_poweroff(device_t);
+int    as3722_reboot(device_t);
 
 #endif /* !_DEV_I2C_AS3722_H */



Home | Main Index | Thread Index | Old Index