diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2023-07-01 15:50:19 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2023-07-01 15:50:19 +0000 |
commit | 03eb5d1c68077846faa1d01c84a5898a33e7d646 (patch) | |
tree | d1138c691d96b4648edc250bd953c16890f15182 | |
parent | 2d589273371b0188fc5db7634c26eace0e8d8981 (diff) |
Enable AC detection in qcpas driver.
Will enable apm -A once cpu P-state driver is added.
-rw-r--r-- | sys/dev/fdt/qcpas.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/dev/fdt/qcpas.c b/sys/dev/fdt/qcpas.c index 1a577427402..36ea06517b7 100644 --- a/sys/dev/fdt/qcpas.c +++ b/sys/dev/fdt/qcpas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qcpas.c,v 1.1 2023/06/10 18:31:38 patrick Exp $ */ +/* $OpenBSD: qcpas.c,v 1.2 2023/07/01 15:50:18 drahn Exp $ */ /* * Copyright (c) 2023 Patrick Wildt <patrick@blueri.se> * @@ -1111,6 +1111,7 @@ struct battmgr_bat_status { uint32_t rate; uint32_t battery_voltage; uint32_t power_state; +#define BATTMGR_PWR_STATE_AC_ON (1 << 0) uint32_t charging_source; #define BATTMGR_CHARGING_SOURCE_AC 1 #define BATTMGR_CHARGING_SOURCE_USB 2 @@ -1175,6 +1176,7 @@ qcpas_pmic_rtr_recv(void *cookie, uint8_t *buf, int len) { struct pmic_glink_hdr hdr; uint32_t notification; + extern int hw_power; if (len < sizeof(hdr)) { printf("%s: pmic glink message too small\n", @@ -1256,6 +1258,14 @@ qcpas_pmic_rtr_recv(void *cookie, uint8_t *buf, int len) info->battery_state = APM_BATT_CHARGING; else if (bat->battery_state & BATTMGR_BAT_STATE_CRITICAL_LOW) info->battery_state = APM_BATT_CRITICAL; + + if (bat->power_state & BATTMGR_PWR_STATE_AC_ON) { + info->ac_state = APM_AC_ON; + hw_power = 1; + } else { + info->ac_state = APM_AC_OFF; + hw_power = 0; + } #endif free(bat, M_TEMP, sizeof(*bat)); break; |