> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs-staging.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 电池限流(BCL)

<a id="bcl-hardware" />

# 配置电池过流和欠压告警

Qualcomm PMIC 电池限流(BCL)硬件监控驱动可实时检测电池过流(放电)和欠压情况。该驱动直接集成到 Qualcomm PMIC 中,通过响应有害的电气事件,在保护电池和整体系统方面发挥关键作用。

BCL 硬件使用带有可配置阈值的专用感测通道监控电池电压和电流。它支持多个告警级别,每个级别都与一条独立的中断线相关联。

**表:BCL 告警功能**

| 告警            | 阈值级别    | 中断线                    |
| ------------- | ------- | ---------------------- |
| Level 0(LVL0) | 最大/最小阈值 | 映射到 `hwmon min/max`    |
| Level 1(LVL1) | 临界阈值    | 映射到 `hwmon lcrit/crit` |

BCL 硬件以两种不同的模式运行:

**表:BCL 模式**

| BCL 模式         | 描述        |
| -------------- | --------- |
| 电池 PMIC 中的 BCL | 支持欠压和过流监控 |
| 核心 PMIC 中的 BCL | 仅支持欠压监控   |

## `sysfs` 属性

驱动加载后,会检测系统上存在的传感器,并在 `/sys/class/hwmon/hwmon<X>/` 下创建相应的 `sysfs` 属性,其中 `<X>` 是根据系统中其他 `hwmon` 设备的存在情况和顺序分配的索引。

### 电池 PMIC 属性

电池 PMIC(例如 PM7250B)中的 BCL 支持以下属性:

**表:电池 PMIC 中支持的 BCL 属性**

| PMIC 名称            | 权限      | 描述                   |
| ------------------ | ------- | -------------------- |
| `curr1_input`      | 只读(RO)  | 电流,单位为毫安(mA)         |
| `curr1_label`      | RO      | 电流传感器标签              |
| `curr1_max`        | 读/写(RW) | Level 0 电流阈值,单位为 mA  |
| `curr1_max_alarm`  | RO      | Level 0 高电流告警状态      |
| `curr1_crit`       | RW      | Level 1 电流阈值,单位为 mA  |
| `curr1_crit_alarm` | RO      | Level 1 高电流告警状态      |
| `in0_input`        | RO      | 电压,单位为毫伏(mV)         |
| `in0_label`        | RO      | 电压传感器标签              |
| `in0_min`          | RW      | Level 0 低电压阈值,单位为 mV |
| `in0_min_alarm`    | RO      | Level 0 低电压告警状态      |
| `in0_lcrit`        | RW      | Level 1 低电压阈值,单位为 mV |
| `in0_lcrit_alarm`  | RO      | Level 1 低电压告警状态      |

> **注意**
>
> * 超过阈值时,告警属性会自动更新。
> * 可以在运行时通过 RW 属性配置阈值。

以下是电池 PMIC 的 `sysfs` 结构示例:

```text theme={null}
-rw-r--r-- 1 root root 4096 Jan  1 00:05 curr1_crit
-r--r--r-- 1 root root 4096 Jan  1 00:05 curr1_crit_alarm
-r--r--r-- 1 root root 4096 Jan  1 00:05 curr1_input
-r--r--r-- 1 root root 4096 Jan  1 00:05 curr1_label
-rw-r--r-- 1 root root 4096 Jan  1 00:05 curr1_max
-r--r--r-- 1 root root 4096 Jan  1 00:05 curr1_max_alarm
lrwxrwxrwx 1 root root    0 Jan  1 00:05 device -> ../../../c440000.spmi:pmic@8:bcl@1d00
-r--r--r-- 1 root root 4096 Jan  1 00:05 in0_input
-r--r--r-- 1 root root 4096 Jan  1 00:05 in0_label
-rw-r--r-- 1 root root 4096 Jan  1 00:05 in0_lcrit
-r--r--r-- 1 root root 4096 Jan  1 00:05 in0_lcrit_alarm
-rw-r--r-- 1 root root 4096 Jan  1 00:05 in0_min
-r--r--r-- 1 root root 4096 Jan  1 00:05 in0_min_alarm
-r--r--r-- 1 root root 4096 Jan  1 00:05 name
```

### 核心 PMIC 属性

核心 PMIC(例如 PM8350C)中的 BCL 支持以下属性:

**表:核心 PMIC 中支持的 BCL 属性**

| PMIC 名称           | 权限 | 描述                   |
| ----------------- | -- | -------------------- |
| `in0_label`       | RO | 电压传感器标签              |
| `in0_min`         | RW | Level 0 低电压阈值,单位为 mV |
| `in0_min_alarm`   | RO | Level 0 低电压告警状态      |
| `in0_lcrit`       | RW | Level 1 低电压阈值,单位为 mV |
| `in0_lcrit_alarm` | RO | Level 1 低电压告警状态      |

> **注意**
>
> * 超过阈值时,告警属性会自动更新。
> * 可以在运行时通过 RW 属性配置阈值。

以下是核心 PMIC 的 `sysfs` 结构示例:

```text theme={null}
-r--r--r-- 1 root root 4096 Jan  1 00:03 in0_label
-rw-r--r-- 1 root root 4096 Jan  1 00:03 in0_lcrit
-r--r--r-- 1 root root 4096 Jan  1 00:03 in0_lcrit_alarm
-rw-r--r-- 1 root root 4096 Jan  1 00:03 in0_min
-r--r--r-- 1 root root 4096 Jan  1 00:03 in0_min_alarm
-r--r--r-- 1 root root 4096 Jan  1 00:03 name
lrwxrwxrwx 1 root root    0 Jan  1 00:03 of_node ->
```

要了解有关 Qualcomm PMIC BCL 的更多信息,请参阅 [Patch series of Qualcomm PMIC BCL](https://lore.kernel.org/all/20260206-qcom-bcl-hwmon-v1-0-7b426f0b77a1@oss.qualcomm.com/)。

## 后续步骤

* [使用风扇控制器调节温度](regulate-temperature-with-fan-controller)
