Skip to content

Commit 271d173

Browse files
authored
hwmon: Add Qualcomm PMIC BCL hardware monitor driver (#424)
hwmon: Add Qualcomm PMIC BCL hardware monitor driver
2 parents 692bea2 + 11e8f87 commit 271d173

10 files changed

Lines changed: 1464 additions & 0 deletions

File tree

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/hwmon/qcom,bcl-hwmon.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Qualcomm SPMI PMIC Battery Current Limiting (BCL) Hardware Monitor
8+
9+
maintainers:
10+
- Manaf Meethalavalappu Pallikunhi <manaf.pallikunhi@oss.qualcomm.com>
11+
12+
description: |
13+
SPMI PMIC Battery Current Limiting (BCL) hardware provides monitoring and
14+
alarm functionality for battery overcurrent and battery or system under
15+
voltage conditions. It monitors battery voltage and current, and
16+
can trigger interrupts when configurable thresholds are exceeded.
17+
18+
properties:
19+
compatible:
20+
oneOf:
21+
- description: v1 based BCL
22+
items:
23+
- enum:
24+
- qcom,pm7250b-bcl
25+
- qcom,pm8250b-bcl
26+
- const: qcom,bcl-v1
27+
28+
- description: v2 based BCL
29+
items:
30+
- enum:
31+
- qcom,pm8350b-bcl
32+
- qcom,pm8350c-bcl
33+
- const: qcom,bcl-v2
34+
35+
- description: v3 bmx based BCL
36+
items:
37+
- enum:
38+
- qcom,pm8550b-bcl
39+
- qcom,pm7550ba-bcl
40+
- const: qcom,bcl-v3-bmx
41+
42+
- description: v3 core based BCL
43+
items:
44+
- enum:
45+
- qcom,pm8550-bc0l
46+
- qcom,pm7550-bcl
47+
- const: qcom,bcl-v3-core
48+
49+
- description: v3 wb based BCL
50+
items:
51+
- enum:
52+
- qcom,pmw5100-bcl
53+
- const: qcom,bcl-v3-wb
54+
55+
- description: v4 bmx based BCL
56+
items:
57+
- enum:
58+
- qcom,pmih010-bcl
59+
- const: qcom,bcl-v4-bmx
60+
61+
- description: v4 bmx with different scale based BCL
62+
items:
63+
- enum:
64+
- qcom,pmv010-bcl
65+
- const: qcom,bcl-v4-pmv010
66+
67+
- description: v4 core based BCL
68+
items:
69+
- enum:
70+
- qcom,pmh010-bcl
71+
- const: qcom,bcl-v4-core
72+
73+
- description: v4 wb based BCL
74+
items:
75+
- enum:
76+
- qcom,pmw6100-bcl
77+
- const: qcom,bcl-v4-wb
78+
79+
reg:
80+
maxItems: 1
81+
description: BCL base address in the SPMI PMIC register map
82+
83+
interrupts:
84+
minItems: 2
85+
maxItems: 2
86+
description:
87+
BCL alarm interrupts for different threshold levels
88+
89+
interrupt-names:
90+
items:
91+
- const: bcl-max-min
92+
- const: bcl-critical
93+
94+
overcurrent-thresholds-milliamp:
95+
description:
96+
Current thresholds in milliamperes for the two configurable current
97+
alarm levels (max and critical). These values are used to override
98+
default thresholds if a platform has different battery ocp specification.
99+
$ref: /schemas/types.yaml#/definitions/uint32-array
100+
minItems: 2
101+
maxItems: 2
102+
103+
required:
104+
- compatible
105+
- reg
106+
- interrupts
107+
- interrupt-names
108+
109+
unevaluatedProperties: false
110+
111+
examples:
112+
- |
113+
#include <dt-bindings/interrupt-controller/irq.h>
114+
115+
pmic {
116+
#address-cells = <1>;
117+
#size-cells = <0>;
118+
119+
sensor@1d00 {
120+
compatible = "qcom,pm7250b-bcl", "qcom,bcl-v1";
121+
reg = <0x1d00>;
122+
interrupts = <0x2 0x1d 0x0 IRQ_TYPE_EDGE_RISING>,
123+
<0x2 0x1d 0x1 IRQ_TYPE_EDGE_RISING>;
124+
interrupt-names = "bcl-max-min",
125+
"bcl-critical";
126+
overcurrent-thresholds-milliamp = <5500 6000>;
127+
};
128+
};

Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ patternProperties:
184184
type: object
185185
$ref: /schemas/rtc/qcom-pm8xxx-rtc.yaml#
186186

187+
"^sensor@[0-9a-f]+$":
188+
type: object
189+
$ref: /schemas/hwmon/qcom,bcl-hwmon.yaml#
190+
187191
"^temp-alarm@[0-9a-f]+$":
188192
type: object
189193
$ref: /schemas/thermal/qcom,spmi-temp-alarm.yaml#

MAINTAINERS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21056,6 +21056,15 @@ S: Maintained
2105621056
F: Documentation/devicetree/bindings/net/qcom,bam-dmux.yaml
2105721057
F: drivers/net/wwan/qcom_bam_dmux.c
2105821058

21059+
QUALCOMM BCL HARDWARE MONITOR DRIVER
21060+
M: Manaf Meethalavalappu Pallikunhi <manaf.pallikunhi@oss.qualcomm.com>
21061+
L: linux-hwmon@vger.kernel.org
21062+
L: linux-arm-msm@vger.kernel.org
21063+
S: Maintained
21064+
F: Documentation/devicetree/bindings/hwmon/qcom,bcl-hwmon.yaml
21065+
F: drivers/hwmon/qcom-bcl-hwmon.c
21066+
F: drivers/hwmon/qcom-bcl-hwmon.h
21067+
2105921068
QUALCOMM BLUETOOTH DRIVER
2106021069
L: linux-arm-msm@vger.kernel.org
2106121070
S: Maintained

arch/arm64/boot/dts/qcom/pm7250b.dtsi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@
202202
interrupt-controller;
203203
#interrupt-cells = <2>;
204204
};
205+
206+
sensor@1d00 {
207+
compatible = "qcom,pm7250b-bcl", "qcom,bcl-v1";
208+
reg = <0x1d00>;
209+
interrupts = <PM7250B_SID 0x1d 0x0 IRQ_TYPE_EDGE_RISING>,
210+
<PM7250B_SID 0x1d 0x1 IRQ_TYPE_EDGE_RISING>;
211+
interrupt-names = "bcl-max-min",
212+
"bcl-critical";
213+
overcurrent-thresholds-milliamp = <5500 6000>;
214+
};
205215
};
206216

207217
pmic@PM7250B_SID1 {

arch/arm64/boot/dts/qcom/pm8350c.dtsi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@
4141
#pwm-cells = <2>;
4242
status = "disabled";
4343
};
44+
45+
sensor@4700 {
46+
compatible = "qcom,pm8350c-bcl", "qcom,bcl-v2";
47+
reg = <0x4700>;
48+
interrupts = <0x2 0x47 0x0 IRQ_TYPE_EDGE_RISING>,
49+
<0x2 0x47 0x1 IRQ_TYPE_EDGE_RISING>;
50+
interrupt-names = "bcl-max-min",
51+
"bcl-critical";
52+
};
4453
};
4554
};
4655

arch/arm64/configs/qcom.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ CONFIG_STM_SOURCE_FTRACE=m
5454
CONFIG_STM_SOURCE_HEARTBEAT=m
5555
CONFIG_SENSORS_AMC6821=y
5656
CONFIG_SENSORS_EMC2305=y
57+
CONFIG_SENSORS_QCOM_BCL=y
5758
CONFIG_TRACE_MMIO_ACCESS=y
5859
CONFIG_UCLAMP_TASK_GROUP=y
5960
CONFIG_UCLAMP_TASK=y

drivers/hwmon/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,15 @@ config SENSORS_PWM_FAN
18931893
This driver can also be built as a module. If so, the module
18941894
will be called pwm-fan.
18951895

1896+
config SENSORS_QCOM_BCL
1897+
tristate "Qualcomm BCL hardware monitoring"
1898+
help
1899+
Say yes here to enable support for Qualcomm battery over current
1900+
and under voltage alarms monitor.
1901+
1902+
This driver can also be built as a module. If so, the module
1903+
will be called qcom-bcl-hwmon.
1904+
18961905
config SENSORS_QNAP_MCU_HWMON
18971906
tristate "QNAP MCU hardware monitoring"
18981907
depends on MFD_QNAP_MCU

drivers/hwmon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ obj-$(CONFIG_SENSORS_POWERZ) += powerz.o
196196
obj-$(CONFIG_SENSORS_POWR1220) += powr1220.o
197197
obj-$(CONFIG_SENSORS_PT5161L) += pt5161l.o
198198
obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o
199+
obj-$(CONFIG_SENSORS_QCOM_BCL) += qcom-bcl-hwmon.o
199200
obj-$(CONFIG_SENSORS_QNAP_MCU_HWMON) += qnap-mcu-hwmon.o
200201
obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o
201202
obj-$(CONFIG_SENSORS_SA67MCU) += sa67mcu-hwmon.o

0 commit comments

Comments
 (0)