MSM8909+Android5.1.1电池管理(2)--qpnp-linear-charger.txt驱动学习概要
参考文件
\kernel\Documentation\power\qpnp-linear-charger.txt---下面是学习此文件
\kernel\Documentation\devicetree\bindings\power\qpnp-linear-charger.txt
1. 简介
The QPNP linear charger driver implementsinput and external peripheral power management for 8916 chipsets. The input canbe supplied to the device via USB path. Output paths is the VPH_PWR rail.
QPNP线性充电器驱动实现8916芯片集(msm8916和pm8916)输入和外部外围电路管理,通过USB路径输入到设备和输出路径是VPH_PWR。
2. 软件描述
2.1 设计目标
The qpnp-linear-charger driver interacts asa consumer and producer for
various input and output power information,as well as relaying information
to userspace.
qpnp-linear-charger驱动作为一个消费者和生产者交互各种输入和输出电源信息,而且转发这些信息给用户空间
Given the abundance of configurations fordifferent board designs it is important to distinguish between configurationswhich are required versus those available to be configured at compile and atrun time. The target of this design is to achieve this as follows:
为不同板设计给出丰富的配置,重要的是可区分编译时需配置的配置和运行时配置,这个设计目的可通过下面的内容来达到:
(1) 编译时选项在设备树文件定义
参考Documentation/devicetree/bindings/power/qpnp-linear-charger.txt,对应设备树文件\kernel\arch\arm\boot\dts\qcom\msm-pm8909.dtsi下的设备节点
pm8909_chg: qcom,charger {
spmi-dev-container;
compatible= "qcom,qpnp-linear-charger";
#address-cells= <1>;
#size-cells= <1>;
…
};
(2) 运行时配置通过power supply框架来实现
(3) 依赖芯片组的特性和工作区(workarounds)通过运行时subtype检测来配合,典型情况不需要改变
Chipset dependent features and workaroundsare configured via runtime subtype detection and are typically not changed.
2.2 Power supply属性实现
While the power supply frameworkimplementation supplies basic definitions
of each property this documentation willdefine the ones used in more detail.
Power supply框架基于定义的每个输定来实现supply,qpnp-linear-charger.txt文档更详细定义这些属性的使用
The notification model in the power supplyframework is used to notify other
consumers of information conveyed by thecharger driver as outlined below.
Each notification is handled via the supplysupplicant relationship.
Whenever a supply is changed and thepower_supply_changed API is called the
external_power_supply_changed callback willbe invoked at the supplicant.
One can picture the notification as onedirectional.
Power supply框架的通知模型用于通知其他消费者信息,这些信息是有充电器驱动传达的,通知模型如下图,每个通知都会通过供应者和请求者的关系来处理,只要是一个供应者状态改变且它调用了power_supply_changed(),请求者就会调用提供者的external_power_changed()回调函数
图1
Registered supplies in qpnp-linear-charger:
*battery
Other supplies in other drivers:
*bms: registered in the Battery Management (BMS) qpnp-vm-bms.c driver.
*usb: registered in the corresponding dwc3 or msm_otg driver.
qpnp-linear-charger注册为名为battery的供应者,qpnp-vm-bms.c驱动注册为bms供应者,phy-msm-usb.c驱动注册为usb的供应者
Battery:
*supplicants: bms
*supplies: bms, usb
图2
* writable properties(可写属性):
-POWER_SUPPLY_PROP_CHARGING_ENABLED
This bit allows to disable current from entering the battery
as well as disabling any current being drawn from external inputs.
此位允许禁用进入电池的电流,也禁来之外部输入的任何电流
- POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL
The temperature level is used by the thermal daemon to configure
the maximum battery current input limit to reduce heat produced
from the battery when charging.
当充电时,守护进程使用温度等级来配置最大电池电流输入限制,从而降低电池产生的热量。
- POWER_SUPPLY_PROP_VOLTAGE_MIN
The minimum input voltage for a given input to the charger.
充电器最小输入电压
- POWER_SUPPLY_PROP_COOL_TEMP
Allows to configure a cool threshold notification which is
configured via the ADC battery temperaturemonitoring API.
允许配置一个cool阈值通知,此阈值通过ADC电池温度监控API来配置
- POWER_SUPPLY_PROP_WARM_TEMP
Allows to configure a warm threshold notification which is
configured via the ADC battery temperaturemonitoring API.
允许配置一个warm阈值通知,此阈值通过ADC电池温度监控API来配置
- POWER_SUPPLY_PROP_STATUS
This property is set by BMS whenever BMSdetects end of charge
condition. Charger driver uses this to stopcharging.
当BMS检测到充电结束,BMS设置此属性来通知充电器多功能停止充电
- POWER_SUPPLY_PROP_CAPACITY
This property is set by the BMS supply whenever the capacity of the
battery is changed. If there is no BMS supplypresent a default
value is returned. This property can also bemanually overridden
from userspace to set a fake capacity. Thisfeature allows for test
environments to prevent certain userspacesfrom shutting down the
device.
当电池容量改变,BMS设置此属性,如果没有BMS,默认为50%。此属性也可被用户空间手动修改来设置一个假的容量。此特征允许测试环境防止某些用户空间关机。
*other notable properties:
-POWER_SUPPLY_PROP_PRESENT:
Indicates whether valid voltage has been detected on either
BATT_THERMor BATT_ID.
指示是否可以通过BATT_THERM或是BATT_ID检测到有效的电压,也就是电池是否存在
Note that the Battery Management (BMS)supply is a special case as there is
a circular notification requirement of theSTATUS (battery) and the CAPACITY
(bms) properties.
请注意,BMS是一个需要循环通知电池状态和容量(bms)属的特殊实例。
The battery power supply is also asupplicant to BMS because of userspace
not being aware of the BMS power supplytype. Thus the CAPACITY property needs
to be relayed through the appropriatebattery supply type.
battery电源供应也是BMS的请求者,因为用户空间不知道BMS电源供应类型,所以电池容量属性需要通过适当的电源供应类型类传达。
2.3 充电驱动配置选项Configoptions
配置文件通过CONFIG_QPNP_LINEAR_CHARGER=y来使能QPNP充电器的支持
2.4 用户空间工具User spaceutilities
The power supply framework sends ueventswhenever power_supply_changed is
invoked. Said event contains the name ofthe supply changed as well as all
implemented power supply properties.
当调用了power_supply_changed(),power supply框架层发送uevents,所说的event包含改变的供应者名称(比如bms、battery、usb),也包含电源供应者实现的属性。
The qpnp-linear-charger driver takesadvantage of the framework to notify
userspace. There are a few userspaceapplications which take advantage of
this information to track things likebattery capacity, presence and health.
qpnp-linear-charger驱动利用power supply框架通知用户空间,有一些用户空间应用运用这些信息来跟踪电池容量(也是百分比)、电池是否存在和生命值(health,比如good)