diff options
author | Frederic Cambus <fcambus@cvs.openbsd.org> | 2016-11-15 13:53:36 +0000 |
---|---|---|
committer | Frederic Cambus <fcambus@cvs.openbsd.org> | 2016-11-15 13:53:36 +0000 |
commit | c870b9da496f0eefecfb6fddac9cc3d76f65d30e (patch) | |
tree | 8731c22dca233294bf1c8237f8d78a528cba4dea | |
parent | d5883b93efb1343eac9c4d5697f6d9f8e051ac6a (diff) |
Add support for lid state detection in ykbec(4).
Tested on a Lemote Yeeloong 8101B.
OK visa@, looks good to deraadt@
-rw-r--r-- | share/man/man4/man4.loongson/ykbec.4 | 8 | ||||
-rw-r--r-- | sys/arch/loongson/dev/kb3310.c | 17 |
2 files changed, 18 insertions, 7 deletions
diff --git a/share/man/man4/man4.loongson/ykbec.4 b/share/man/man4/man4.loongson/ykbec.4 index 169325f3728..0adfd1b4cfa 100644 --- a/share/man/man4/man4.loongson/ykbec.4 +++ b/share/man/man4/man4.loongson/ykbec.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ykbec.4,v 1.3 2010/02/25 10:07:11 jmc Exp $ +.\" $OpenBSD: ykbec.4,v 1.4 2016/11/15 13:53:35 fcambus Exp $ .\" .\" Copyright (c) 2010 Otto Moerbeek .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 25 2010 $ +.Dd $Mdocdate: November 15 2016 $ .Dt YKBEC 4 loongson .Os .Sh NAME @@ -40,9 +40,11 @@ Battery control Button events .It Power management +.It +Lid state .El .Pp -Fan and battery information is made available via the +Fan, battery, and lid information is made available via the .Xr sysctl 3 hardware sensor interface. Not all the device interfaces are supported under diff --git a/sys/arch/loongson/dev/kb3310.c b/sys/arch/loongson/dev/kb3310.c index ad4d197a685..d9887dc5a0e 100644 --- a/sys/arch/loongson/dev/kb3310.c +++ b/sys/arch/loongson/dev/kb3310.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kb3310.c,v 1.20 2016/01/08 15:54:13 jcs Exp $ */ +/* $OpenBSD: kb3310.c,v 1.21 2016/11/15 13:53:35 fcambus Exp $ */ /* * Copyright (c) 2010 Otto Moerbeek <otto@drijf.net> * @@ -76,8 +76,10 @@ static const struct { #define YKBEC_CHARGING 7 { "Battery charging", SENSOR_INDICATOR }, #define YKBEC_AC 8 - { "AC-Power", SENSOR_INDICATOR } -#define YKBEC_NSENSORS 9 + { "AC-Power", SENSOR_INDICATOR }, +#define YKBEC_LID 9 + { "Lid open", SENSOR_INDICATOR } +#define YKBEC_NSENSORS 10 }; struct ykbec_softc { @@ -310,6 +312,10 @@ ykbec_read16(struct ykbec_softc *mcsc, u_int reg) #define REG_FAN_ON 1 #define REG_FAN_OFF 0 +#define REG_LID_STATE 0xf4bd +#define LID_OPEN 1 +#define LID_CLOSED 0 + #define YKBEC_SCI_IRQ 0xa #ifdef DEBUG @@ -337,7 +343,7 @@ ykbec_refresh(void *arg) { struct ykbec_softc *sc = (struct ykbec_softc *)arg; u_int val, bat_charge, bat_status, charge_status, bat_state, power_flag; - u_int cap_pct, fullcap; + u_int lid_state, cap_pct, fullcap; int current; #if NAPM > 0 struct apm_power_info old; @@ -376,12 +382,15 @@ ykbec_refresh(void *arg) charge_status = ykbec_read(sc, REG_CHARGE_STATUS); bat_state = ykbec_read(sc, REG_BAT_STATE); power_flag = ykbec_read(sc, REG_POWER_FLAG); + lid_state = ykbec_read(sc, REG_LID_STATE); sc->sc_sensor[YKBEC_CHARGING].value = !!ISSET(bat_state, BAT_STATE_CHARGING); sc->sc_sensor[YKBEC_AC].value = !!ISSET(power_flag, POWER_FLAG_ADAPTER_IN); + sc->sc_sensor[YKBEC_LID].value = !!ISSET(lid_state, LID_OPEN); + sc->sc_sensor[YKBEC_CAP].status = ISSET(bat_status, BAT_STATUS_BAT_LOW) ? SENSOR_S_CRIT : SENSOR_S_OK; |