Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:
"battery/charger driver changes:
- core:
- provide function stubs if CONFIG_POWER_SUPPLY=n
- reduce loglevel for probe defer info
- surface:
- new battery and charger drivers for Surface
- bq27xxx:
- add bq78z100 support
- fix current_now/power_avg for newer chips
- cw2015:
- add CHARGE_NOW support
- ab8500:
- drop pdata support
- convert most DT bindings to YAML
- lots of minor fixes and cleanups

reset drivers:
- ltc2952-poweroff:
- make trigger delay configurable from DT
- minor fixes and cleanups"

* tag 'for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (97 commits)
power: supply: cpcap-battery: fix invalid usage of list cursor
power: supply: bq256xx: add kerneldoc for structure members
power: supply: act8945a: correct kerneldoc
power: supply: max17040: remove unneeded double cast
power: supply: max17040: handle device_property_read_u8_array() failure
power: supply: max14577: remove unneeded variable initialization
power: supply: surface-charger: Make symbol 'surface_ac_pm_ops' static
power: supply: surface-battery: Make some symbols static
power: reset: restart-poweroff: Add missing MODULE_DEVICE_TABLE
power: reset: hisi-reboot: add missing MODULE_DEVICE_TABLE
power: supply: s3c_adc_battery: fix possible use-after-free in s3c_adc_bat_remove()
power: supply: generic-adc-battery: fix possible use-after-free in gab_remove()
power: supply: Add AC driver for Surface Aggregator Module
power: supply: Add battery driver for Surface Aggregator Module
power: supply: bq25980: Move props from battery node
power: supply: core: Use true and false for bool variable
power: supply: goldfish: Remove the GOLDFISH dependency
power: reset: ltc2952: make trigger delay configurable
power: supply: cpcap-charger: Simplify bool conversion
power: supply: cpcap-charger: Add usleep to cpcap charger to avoid usb plug bounce
...

+5213 -2666
+15
Documentation/ABI/testing/sysfs-class-power-surface
··· 1 + What: /sys/class/power_supply/<supply_name>/alarm 2 + Date: April 2021 3 + KernelVersion: 5.13 4 + Contact: Maximilian Luz <luzmaximilian@gmail.com> 5 + Description: 6 + Battery trip point. When the remaining battery capacity crosses this 7 + value in either direction, the system will be notified and if 8 + necessary woken. 9 + 10 + Set to zero to clear/disable. 11 + 12 + Access: Read, Write 13 + 14 + Valid values: In micro-Wh or micro-Ah, depending on the power unit 15 + of the battery
+4
Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt
··· 17 17 chip's trigger line. If this property is not set, the 18 18 trigger function is ignored and the chip is kept alive 19 19 until an explicit kill signal is received 20 + - trigger-delay-ms The number of milliseconds to wait after trigger line 21 + assertion before executing shut down procedure. 22 + The default is 2500ms. 20 23 21 24 Example: 22 25 ··· 27 24 compatible = "lltc,ltc2952"; 28 25 29 26 trigger-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>; 27 + trigger-delay-ms = <2000>; 30 28 watchdog-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>; 31 29 kill-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; 32 30 };
-16
Documentation/devicetree/bindings/power/supply/ab8500/btemp.txt
··· 1 - === AB8500 Battery Temperature Monitor Driver === 2 - 3 - The properties below describes the node for btemp driver. 4 - 5 - Required Properties: 6 - - compatible = Shall be: "stericsson,ab8500-btemp" 7 - - battery = Shall be battery specific information 8 - 9 - Example: 10 - ab8500_btemp { 11 - compatible = "stericsson,ab8500-btemp"; 12 - battery = <&ab8500_battery>; 13 - }; 14 - 15 - For information on battery specific node, Ref: 16 - Documentation/devicetree/bindings/power/supply/ab8500/fg.txt
-16
Documentation/devicetree/bindings/power/supply/ab8500/chargalg.txt
··· 1 - === AB8500 Charging Algorithm Driver === 2 - 3 - The properties below describes the node for chargalg driver. 4 - 5 - Required Properties: 6 - - compatible = Shall be: "stericsson,ab8500-chargalg" 7 - - battery = Shall be battery specific information 8 - 9 - Example: 10 - ab8500_chargalg { 11 - compatible = "stericsson,ab8500-chargalg"; 12 - battery = <&ab8500_battery>; 13 - }; 14 - 15 - For information on battery specific node, Ref: 16 - Documentation/devicetree/bindings/power/supply/ab8500/fg.txt
-25
Documentation/devicetree/bindings/power/supply/ab8500/charger.txt
··· 1 - === AB8500 Charger Driver === 2 - 3 - Required Properties: 4 - - compatible = Shall be "stericsson,ab8500-charger" 5 - - battery = Shall be battery specific information 6 - Example: 7 - ab8500_charger { 8 - compatible = "stericsson,ab8500-charger"; 9 - battery = <&ab8500_battery>; 10 - }; 11 - 12 - - vddadc-supply: Supply for USB and Main charger 13 - Example: 14 - ab8500-charger { 15 - vddadc-supply = <&ab8500_ldo_tvout_reg>; 16 - } 17 - - autopower_cfg: 18 - Boolean value depicting the presence of 'automatic poweron after powerloss' 19 - Example: 20 - ab8500-charger { 21 - autopower_cfg; 22 - }; 23 - 24 - For information on battery specific node, Ref: 25 - Documentation/devicetree/bindings/power/supply/ab8500/fg.txt
-58
Documentation/devicetree/bindings/power/supply/ab8500/fg.txt
··· 1 - === AB8500 Fuel Gauge Driver === 2 - 3 - AB8500 is a mixed signal multimedia and power management 4 - device comprising: power and energy-management-module, 5 - wall-charger, usb-charger, audio codec, general purpose adc, 6 - tvout, clock management and sim card interface. 7 - 8 - Fuelgauge support is part of energy-management-modules, other 9 - components of this module are: 10 - main-charger, usb-combo-charger and battery-temperature-monitoring. 11 - 12 - The properties below describes the node for fuelgauge driver. 13 - 14 - Required Properties: 15 - - compatible = This shall be: "stericsson,ab8500-fg" 16 - - battery = Shall be battery specific information 17 - Example: 18 - ab8500_fg { 19 - compatible = "stericsson,ab8500-fg"; 20 - battery = <&ab8500_battery>; 21 - }; 22 - 23 - dependent node: 24 - ab8500_battery: ab8500_battery { 25 - }; 26 - This node will provide information on 'thermistor interface' and 27 - 'battery technology type' used. 28 - 29 - Properties of this node are: 30 - thermistor-on-batctrl: 31 - A boolean value indicating thermistor interface to battery 32 - 33 - Note: 34 - 'btemp' and 'batctrl' are the pins interfaced for battery temperature 35 - measurement, 'btemp' signal is used when NTC(negative temperature 36 - coefficient) resister is interfaced external to battery whereas 37 - 'batctrl' pin is used when NTC resister is internal to battery. 38 - 39 - Example: 40 - ab8500_battery: ab8500_battery { 41 - thermistor-on-batctrl; 42 - }; 43 - indicates: NTC resister is internal to battery, 'batctrl' is used 44 - for thermal measurement. 45 - 46 - The absence of property 'thermal-on-batctrl' indicates 47 - NTC resister is external to battery and 'btemp' signal is used 48 - for thermal measurement. 49 - 50 - battery-type: 51 - This shall be the battery manufacturing technology type, 52 - allowed types are: 53 - "UNKNOWN" "NiMH" "LION" "LIPO" "LiFe" "NiCd" "LiMn" 54 - Example: 55 - ab8500_battery: ab8500_battery { 56 - stericsson,battery-type = "LIPO"; 57 - } 58 -
-44
Documentation/devicetree/bindings/power/supply/act8945a-charger.txt
··· 1 - Device-Tree bindings for charger of Active-semi ACT8945A Multi-Function Device 2 - 3 - Required properties: 4 - - compatible: "active-semi,act8945a-charger". 5 - - active-semi,chglev-gpios: charge current level phandle with args 6 - as described in ../gpio/gpio.txt. 7 - - active-semi,lbo-gpios: specify the low battery voltage detect phandle 8 - with args as as described in ../gpio/gpio.txt. 9 - - interrupts: <a b> where a is the interrupt number and b is a 10 - field that represents an encoding of the sense and level 11 - information for the interrupt. 12 - 13 - Optional properties: 14 - - active-semi,input-voltage-threshold-microvolt: unit: mV; 15 - Specifies the charger's input over-voltage threshold value; 16 - The value can be: 6600, 7000, 7500, 8000; default: 6600 17 - - active-semi,precondition-timeout: unit: minutes; 18 - Specifies the charger's PRECONDITION safety timer setting value; 19 - The value can be: 40, 60, 80, 0; If 0, it means to disable this timer; 20 - default: 40. 21 - - active-semi,total-timeout: unit: hours; 22 - Specifies the charger's total safety timer setting value; 23 - The value can be: 3, 4, 5, 0; If 0, it means to disable this timer; 24 - default: 3. 25 - 26 - Example: 27 - pmic@5b { 28 - compatible = "active-semi,act8945a"; 29 - reg = <0x5b>; 30 - 31 - charger { 32 - compatible = "active-semi,act8945a-charger"; 33 - pinctrl-names = "default"; 34 - pinctrl-0 = <&pinctrl_charger_chglev &pinctrl_charger_lbo &pinctrl_charger_irq>; 35 - interrupt-parent = <&pioA>; 36 - interrupts = <45 IRQ_TYPE_LEVEL_LOW>; 37 - 38 - active-semi,chglev-gpios = <&pioA 12 GPIO_ACTIVE_HIGH>; 39 - active-semi,lbo-gpios = <&pioA 72 GPIO_ACTIVE_LOW>; 40 - active-semi,input-voltage-threshold-microvolt = <6600>; 41 - active-semi,precondition-timeout = <40>; 42 - active-semi,total-timeout = <3>; 43 - }; 44 - };
+76
Documentation/devicetree/bindings/power/supply/active-semi,act8945a-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/active-semi,act8945a-charger.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Active-semi ACT8945A Charger Function 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: active-semi,act8945a-charger 18 + 19 + interrupts: 20 + maxItems: 1 21 + 22 + active-semi,chglev-gpios: 23 + maxItems: 1 24 + description: charge current level GPIO 25 + 26 + active-semi,lbo-gpios: 27 + maxItems: 1 28 + description: low battery voltage detect GPIO 29 + 30 + active-semi,input-voltage-threshold-microvolt: 31 + description: | 32 + Specifies the charger's input over-voltage threshold value. 33 + Despite the name, specified values are in millivolt (mV). 34 + Defaults to 6.6 V 35 + enum: [ 6600, 7000, 7500, 8000 ] 36 + 37 + active-semi,precondition-timeout: 38 + $ref: /schemas/types.yaml#/definitions/uint32 39 + description: | 40 + Specifies the charger's PRECONDITION safety timer setting value in minutes. 41 + If 0, it means to disable this timer. 42 + Defaults to 40 minutes. 43 + enum: [ 0, 40, 60, 80 ] 44 + 45 + active-semi,total-timeout: 46 + $ref: /schemas/types.yaml#/definitions/uint32 47 + description: | 48 + Specifies the charger's total safety timer setting value in hours; 49 + If 0, it means to disable this timer; 50 + Defaults to 3 hours. 51 + enum: [ 0, 3, 4, 5 ] 52 + 53 + required: 54 + - compatible 55 + - interrupts 56 + - active-semi,chglev-gpios 57 + - active-semi,lbo-gpios 58 + 59 + additionalProperties: false 60 + 61 + examples: 62 + - | 63 + #include <dt-bindings/gpio/gpio.h> 64 + #include <dt-bindings/interrupt-controller/irq.h> 65 + pmic { 66 + charger { 67 + compatible = "active-semi,act8945a-charger"; 68 + interrupt-parent = <&pioA>; 69 + interrupts = <45 IRQ_TYPE_LEVEL_LOW>; 70 + active-semi,chglev-gpios = <&pioA 12 GPIO_ACTIVE_HIGH>; 71 + active-semi,lbo-gpios = <&pioA 72 GPIO_ACTIVE_LOW>; 72 + active-semi,input-voltage-threshold-microvolt = <6600>; 73 + active-semi,precondition-timeout = <40>; 74 + active-semi,total-timeout = <3>; 75 + }; 76 + };
-25
Documentation/devicetree/bindings/power/supply/axp20x_ac_power.txt
··· 1 - AXP20X and AXP22X PMICs' AC power supply 2 - 3 - Required Properties: 4 - - compatible: One of: 5 - "x-powers,axp202-ac-power-supply" 6 - "x-powers,axp221-ac-power-supply" 7 - "x-powers,axp813-ac-power-supply" 8 - 9 - This node is a subnode of the axp20x PMIC. 10 - 11 - The AXP20X can read the current current and voltage supplied by AC by 12 - reading ADC channels from the AXP20X ADC. 13 - 14 - The AXP22X is only able to tell if an AC power supply is present and 15 - usable. 16 - 17 - AXP813/AXP803 are able to limit current and supply voltage 18 - 19 - Example: 20 - 21 - &axp209 { 22 - ac_power_supply: ac-power-supply { 23 - compatible = "x-powers,axp202-ac-power-supply"; 24 - }; 25 - };
-20
Documentation/devicetree/bindings/power/supply/axp20x_battery.txt
··· 1 - AXP20x and AXP22x battery power supply 2 - 3 - Required Properties: 4 - - compatible, one of: 5 - "x-powers,axp209-battery-power-supply" 6 - "x-powers,axp221-battery-power-supply" 7 - "x-powers,axp813-battery-power-supply" 8 - 9 - This node is a subnode of its respective PMIC DT node. 10 - 11 - The supported devices can read the battery voltage, charge and discharge 12 - currents of the battery by reading ADC channels from the ADC. 13 - 14 - Example: 15 - 16 - &axp209 { 17 - battery_power_supply: battery-power-supply { 18 - compatible = "x-powers,axp209-battery-power-supply"; 19 - } 20 - };
-41
Documentation/devicetree/bindings/power/supply/axp20x_usb_power.txt
··· 1 - AXP20x USB power supply 2 - 3 - Required Properties: 4 - -compatible: One of: "x-powers,axp202-usb-power-supply" 5 - "x-powers,axp221-usb-power-supply" 6 - "x-powers,axp223-usb-power-supply" 7 - "x-powers,axp813-usb-power-supply" 8 - 9 - The AXP223 PMIC shares most of its behaviour with the AXP221 but has slight 10 - variations such as the former being able to set the VBUS power supply max 11 - current to 100mA, unlike the latter. 12 - 13 - This node is a subnode of the axp20x PMIC. 14 - 15 - Example: 16 - 17 - axp209: pmic@34 { 18 - compatible = "x-powers,axp209"; 19 - reg = <0x34>; 20 - interrupt-parent = <&nmi_intc>; 21 - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; 22 - interrupt-controller; 23 - #interrupt-cells = <1>; 24 - 25 - regulators { 26 - x-powers,dcdc-freq = <1500>; 27 - 28 - vdd_cpu: dcdc2 { 29 - regulator-always-on; 30 - regulator-min-microvolt = <1000000>; 31 - regulator-max-microvolt = <1450000>; 32 - regulator-name = "vdd-cpu"; 33 - }; 34 - 35 - ... 36 - }; 37 - 38 - usb-power-supply: usb-power-supply { 39 - compatible = "x-powers,axp202-usb-power-supply"; 40 - }; 41 - };
-3
Documentation/devicetree/bindings/power/supply/battery.txt
··· 1 - The contents of this file has been moved to battery.yaml 2 - 3 - Please note that not all charger drivers respect all of the properties.
-47
Documentation/devicetree/bindings/power/supply/bq2415x.txt
··· 1 - Binding for TI bq2415x Li-Ion Charger 2 - 3 - Required properties: 4 - - compatible: Should contain one of the following: 5 - * "ti,bq24150" 6 - * "ti,bq24150" 7 - * "ti,bq24150a" 8 - * "ti,bq24151" 9 - * "ti,bq24151a" 10 - * "ti,bq24152" 11 - * "ti,bq24153" 12 - * "ti,bq24153a" 13 - * "ti,bq24155" 14 - * "ti,bq24156" 15 - * "ti,bq24156a" 16 - * "ti,bq24158" 17 - - reg: integer, i2c address of the device. 18 - - ti,current-limit: integer, initial maximum current charger can pull 19 - from power supply in mA. 20 - - ti,weak-battery-voltage: integer, weak battery voltage threshold in mV. 21 - The chip will use slow precharge if battery voltage 22 - is below this value. 23 - - ti,battery-regulation-voltage: integer, maximum charging voltage in mV. 24 - - ti,charge-current: integer, maximum charging current in mA. 25 - - ti,termination-current: integer, charge will be terminated when current in 26 - constant-voltage phase drops below this value (in mA). 27 - - ti,resistor-sense: integer, value of sensing resistor in milliohm. 28 - 29 - Optional properties: 30 - - ti,usb-charger-detection: phandle to usb charger detection device. 31 - (required for auto mode) 32 - 33 - Example from Nokia N900: 34 - 35 - bq24150a { 36 - compatible = "ti,bq24150a"; 37 - reg = <0x6b>; 38 - 39 - ti,current-limit = <100>; 40 - ti,weak-battery-voltage = <3400>; 41 - ti,battery-regulation-voltage = <4200>; 42 - ti,charge-current = <650>; 43 - ti,termination-current = <100>; 44 - ti,resistor-sense = <68>; 45 - 46 - ti,usb-charger-detection = <&isp1704>; 47 - };
+98
Documentation/devicetree/bindings/power/supply/bq2415x.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/bq2415x.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Binding for TI bq2415x Li-Ion Charger 9 + 10 + maintainers: 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - ti,bq24150 20 + - ti,bq24150 21 + - ti,bq24150a 22 + - ti,bq24151 23 + - ti,bq24151a 24 + - ti,bq24152 25 + - ti,bq24153 26 + - ti,bq24153a 27 + - ti,bq24155 28 + - ti,bq24156 29 + - ti,bq24156a 30 + - ti,bq24158 31 + 32 + reg: 33 + maxItems: 1 34 + 35 + ti,current-limit: 36 + $ref: /schemas/types.yaml#/definitions/uint32 37 + description: initial maximum current charger can pull from power supply in mA. 38 + 39 + ti,weak-battery-voltage: 40 + $ref: /schemas/types.yaml#/definitions/uint32 41 + description: | 42 + weak battery voltage threshold in mV. 43 + The chip will use slow precharge if battery voltage is below this value. 44 + 45 + ti,battery-regulation-voltage: 46 + $ref: /schemas/types.yaml#/definitions/uint32 47 + description: maximum charging voltage in mV. 48 + 49 + ti,charge-current: 50 + $ref: /schemas/types.yaml#/definitions/uint32 51 + description: maximum charging current in mA. 52 + 53 + ti,termination-current: 54 + $ref: /schemas/types.yaml#/definitions/uint32 55 + description: | 56 + charge will be terminated when current in constant-voltage phase drops 57 + below this value (in mA). 58 + 59 + ti,resistor-sense: 60 + $ref: /schemas/types.yaml#/definitions/uint32 61 + description: value of sensing resistor in milliohm. 62 + 63 + ti,usb-charger-detection: 64 + $ref: /schemas/types.yaml#/definitions/phandle 65 + description: phandle to usb charger detection device (required for auto mode) 66 + 67 + required: 68 + - compatible 69 + - reg 70 + - ti,current-limit 71 + - ti,weak-battery-voltage 72 + - ti,battery-regulation-voltage 73 + - ti,charge-current 74 + - ti,termination-current 75 + - ti,resistor-sense 76 + 77 + additionalProperties: false 78 + 79 + examples: 80 + - | 81 + i2c0 { 82 + #address-cells = <1>; 83 + #size-cells = <0>; 84 + 85 + charger@6b { 86 + compatible = "ti,bq24150a"; 87 + reg = <0x6b>; 88 + 89 + ti,current-limit = <100>; 90 + ti,weak-battery-voltage = <3400>; 91 + ti,battery-regulation-voltage = <4200>; 92 + ti,charge-current = <650>; 93 + ti,termination-current = <100>; 94 + ti,resistor-sense = <68>; 95 + 96 + ti,usb-charger-detection = <&isp1704>; 97 + }; 98 + };
-61
Documentation/devicetree/bindings/power/supply/bq24190.txt
··· 1 - TI BQ24190 Li-Ion Battery Charger 2 - 3 - Required properties: 4 - - compatible: contains one of the following: 5 - * "ti,bq24190" 6 - * "ti,bq24192" 7 - * "ti,bq24192i" 8 - * "ti,bq24196" 9 - - reg: integer, I2C address of the charger. 10 - - interrupts[-extended]: configuration for charger INT pin. 11 - 12 - Optional properties: 13 - - monitored-battery: phandle of battery characteristics devicetree node 14 - The charger uses the following battery properties: 15 - + precharge-current-microamp: maximum charge current during precharge 16 - phase (typically 20% of battery capacity). 17 - + charge-term-current-microamp: a charge cycle terminates when the 18 - battery voltage is above recharge threshold, and the current is below 19 - this setting (typically 10% of battery capacity). 20 - See also Documentation/devicetree/bindings/power/supply/battery.txt 21 - - ti,system-minimum-microvolt: when power is connected and the battery is below 22 - minimum system voltage, the system will be regulated above this setting. 23 - 24 - child nodes: 25 - - usb-otg-vbus: 26 - Usage: optional 27 - Description: Regulator that is used to control the VBUS voltage direction for 28 - either USB host mode or for charging on the OTG port. 29 - 30 - Notes: 31 - - Some circuit boards wire the chip's "OTG" pin high (enabling 500mA default 32 - charge current on USB SDP ports, among other features). To simulate this on 33 - boards that wire the pin to a GPIO, set a gpio-hog. 34 - 35 - Example: 36 - 37 - bat: battery { 38 - compatible = "simple-battery"; 39 - precharge-current-microamp = <256000>; 40 - charge-term-current-microamp = <128000>; 41 - // etc. 42 - }; 43 - 44 - bq24190: charger@6a { 45 - compatible = "ti,bq24190"; 46 - reg = <0x6a>; 47 - interrupts-extended = <&gpiochip 10 IRQ_TYPE_EDGE_FALLING>; 48 - monitored-battery = <&bat>; 49 - ti,system-minimum-microvolt = <3200000>; 50 - 51 - usb_otg_vbus: usb-otg-vbus { }; 52 - }; 53 - 54 - &twl_gpio { 55 - otg { 56 - gpio-hog; 57 - gpios = <6 0>; 58 - output-high; 59 - line-name = "otg-gpio"; 60 - }; 61 - };
+92
Documentation/devicetree/bindings/power/supply/bq24190.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/bq24190.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Binding for TI BQ2419x Li-Ion Battery Charger 9 + 10 + maintainers: 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - ti,bq24190 20 + - ti,bq24192 21 + - ti,bq24192i 22 + - ti,bq24196 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + interrupts: 28 + maxItems: 1 29 + 30 + usb-otg-vbus: 31 + type: object 32 + description: | 33 + Regulator that is used to control the VBUS voltage direction for 34 + either USB host mode or for charging on the OTG port 35 + 36 + ti,system-minimum-microvolt: 37 + description: | 38 + when power is connected and the battery is below minimum system voltage, 39 + the system will be regulated above this setting. 40 + 41 + omit-battery-class: 42 + type: boolean 43 + description: | 44 + If this property is set, the operating system does not try to create a 45 + battery device. 46 + 47 + monitored-battery: 48 + $ref: /schemas/types.yaml#/definitions/phandle 49 + description: | 50 + phandle to a "simple-battery" compatible node. 51 + 52 + This property must be a phandle to a node using the format described 53 + in battery.yaml, with the following properties being required: 54 + - precharge-current-microamp: maximum charge current during precharge phase 55 + (typically 20% of battery capacity). 56 + - charge-term-current-microamp: a charge cycle terminates when the battery voltage is 57 + above recharge threshold, and the current is below this 58 + setting (typically 10% of battery capacity). 59 + 60 + required: 61 + - compatible 62 + - reg 63 + - interrupts 64 + 65 + additionalProperties: false 66 + 67 + examples: 68 + - | 69 + #include <dt-bindings/gpio/gpio.h> 70 + #include <dt-bindings/interrupt-controller/irq.h> 71 + 72 + bat: battery { 73 + compatible = "simple-battery"; 74 + precharge-current-microamp = <256000>; 75 + charge-term-current-microamp = <128000>; 76 + }; 77 + 78 + i2c0 { 79 + #address-cells = <1>; 80 + #size-cells = <0>; 81 + 82 + charger@6a { 83 + compatible = "ti,bq24190"; 84 + reg = <0x6a>; 85 + interrupt-parent = <&gpiochip>; 86 + interrupts = <10 IRQ_TYPE_EDGE_FALLING>; 87 + monitored-battery = <&bat>; 88 + ti,system-minimum-microvolt = <3200000>; 89 + 90 + usb_otg_vbus: usb-otg-vbus { }; 91 + }; 92 + };
-62
Documentation/devicetree/bindings/power/supply/bq24257.txt
··· 1 - Binding for TI bq24250/bq24251/bq24257 Li-Ion Charger 2 - 3 - Required properties: 4 - - compatible: Should contain one of the following: 5 - * "ti,bq24250" 6 - * "ti,bq24251" 7 - * "ti,bq24257" 8 - - reg: integer, i2c address of the device. 9 - - interrupts: Interrupt mapping for GPIO IRQ (configure for both edges). Use in 10 - conjunction with "interrupt-parent". 11 - - ti,battery-regulation-voltage: integer, maximum charging voltage in uV. 12 - - ti,charge-current: integer, maximum charging current in uA. 13 - - ti,termination-current: integer, charge will be terminated when current in 14 - constant-voltage phase drops below this value (in uA). 15 - 16 - Optional properties: 17 - - pg-gpios: GPIO used for connecting the bq2425x device PG (Power Good) pin. 18 - This pin is not available on all devices however it should be used if 19 - possible as this is the recommended way to obtain the charger's input PG 20 - state. If this pin is not specified a software-based approach for PG 21 - detection is used. 22 - - ti,current-limit: The maximum current to be drawn from the charger's input 23 - (in uA). If this property is not specified, the input limit current is 24 - set automatically using USB D+/D- signal based charger type detection. 25 - If the hardware does not support the D+/D- based detection, a default 26 - of 500,000 is used (=500mA) instead. 27 - - ti,ovp-voltage: Configures the over voltage protection voltage (in uV). If 28 - not specified a default of 6,5000,000 (=6.5V) is used. 29 - - ti,in-dpm-voltage: Configures the threshold input voltage for the dynamic 30 - power path management (in uV). If not specified a default of 4,360,000 31 - (=4.36V) is used. 32 - 33 - Example: 34 - 35 - bq24257 { 36 - compatible = "ti,bq24257"; 37 - reg = <0x6a>; 38 - interrupt-parent = <&gpio1>; 39 - interrupts = <16 IRQ_TYPE_EDGE_BOTH>; 40 - 41 - pg-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; 42 - 43 - ti,battery-regulation-voltage = <4200000>; 44 - ti,charge-current = <1000000>; 45 - ti,termination-current = <50000>; 46 - }; 47 - 48 - Example: 49 - 50 - bq24250 { 51 - compatible = "ti,bq24250"; 52 - reg = <0x6a>; 53 - interrupt-parent = <&gpio1>; 54 - interrupts = <16 IRQ_TYPE_EDGE_BOTH>; 55 - 56 - ti,battery-regulation-voltage = <4200000>; 57 - ti,charge-current = <500000>; 58 - ti,termination-current = <50000>; 59 - ti,current-limit = <900000>; 60 - ti,ovp-voltage = <9500000>; 61 - ti,in-dpm-voltage = <4440000>; 62 - };
+124
Documentation/devicetree/bindings/power/supply/bq24257.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/bq24257.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Binding for bq24250, bq24251 and bq24257 Li-Ion Charger 9 + 10 + maintainers: 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - ti,bq24250 20 + - ti,bq24251 21 + - ti,bq24257 22 + 23 + reg: 24 + maxItems: 1 25 + 26 + interrupts: 27 + maxItems: 1 28 + 29 + ti,battery-regulation-voltage: 30 + $ref: /schemas/types.yaml#/definitions/uint32 31 + description: maximum charging voltage in uV 32 + 33 + ti,charge-current: 34 + $ref: /schemas/types.yaml#/definitions/uint32 35 + description: maximum charging current in uA 36 + 37 + ti,termination-current: 38 + $ref: /schemas/types.yaml#/definitions/uint32 39 + description: | 40 + charge will be terminated when current in constant-voltage phase 41 + drops below this value (in uA) 42 + 43 + pg-gpios: 44 + description: | 45 + GPIO used for connecting the bq2425x device PG (Power Good) pin. 46 + This pin is not available on all devices however it should be used if 47 + possible as this is the recommended way to obtain the charger's input PG 48 + state. If this pin is not specified a software-based approach for PG 49 + detection is used. 50 + maxItems: 1 51 + 52 + ti,current-limit: 53 + $ref: /schemas/types.yaml#/definitions/uint32 54 + description: | 55 + The maximum current to be drawn from the charger's input (in uA). 56 + If this property is not specified, the input limit current is set 57 + automatically using USB D+/D- signal based charger type detection. 58 + If the hardware does not support the D+/D- based detection, a default 59 + of 500,000 is used (=500mA) instead. 60 + 61 + ti,ovp-voltage: 62 + $ref: /schemas/types.yaml#/definitions/uint32 63 + description: | 64 + Configures the over voltage protection voltage (in uV). 65 + If not specified a default of 6,5000,000 (=6.5V) is used. 66 + 67 + ti,in-dpm-voltage: 68 + $ref: /schemas/types.yaml#/definitions/uint32 69 + description: | 70 + Configures the threshold input voltage for the dynamic power path management (in uV). 71 + If not specified a default of 4,360,000 (=4.36V) is used. 72 + 73 + required: 74 + - compatible 75 + - reg 76 + - interrupts 77 + - ti,battery-regulation-voltage 78 + - ti,charge-current 79 + - ti,termination-current 80 + 81 + additionalProperties: false 82 + 83 + examples: 84 + - | 85 + #include <dt-bindings/gpio/gpio.h> 86 + #include <dt-bindings/interrupt-controller/irq.h> 87 + i2c0 { 88 + #address-cells = <1>; 89 + #size-cells = <0>; 90 + 91 + charger@6a { 92 + compatible = "ti,bq24257"; 93 + reg = <0x6a>; 94 + interrupt-parent = <&gpio1>; 95 + interrupts = <16 IRQ_TYPE_EDGE_BOTH>; 96 + 97 + pg-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; 98 + 99 + ti,battery-regulation-voltage = <4200000>; 100 + ti,charge-current = <1000000>; 101 + ti,termination-current = <50000>; 102 + }; 103 + }; 104 + - | 105 + #include <dt-bindings/gpio/gpio.h> 106 + #include <dt-bindings/interrupt-controller/irq.h> 107 + i2c0 { 108 + #address-cells = <1>; 109 + #size-cells = <0>; 110 + 111 + charger@6a { 112 + compatible = "ti,bq24250"; 113 + reg = <0x6a>; 114 + interrupt-parent = <&gpio1>; 115 + interrupts = <16 IRQ_TYPE_EDGE_BOTH>; 116 + 117 + ti,battery-regulation-voltage = <4200000>; 118 + ti,charge-current = <500000>; 119 + ti,termination-current = <50000>; 120 + ti,current-limit = <900000>; 121 + ti,ovp-voltage = <9500000>; 122 + ti,in-dpm-voltage = <4440000>; 123 + }; 124 + };
+89
Documentation/devicetree/bindings/power/supply/bq24735.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/bq24735.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Binding for TI BQ24735 Li-Ion Battery Charger 9 + 10 + maintainers: 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + const: ti,bq24735 19 + 20 + reg: 21 + maxItems: 1 22 + 23 + interrupts: 24 + description: AC adapter plug event interrupt 25 + maxItems: 1 26 + 27 + ti,ac-detect-gpios: 28 + maxItems: 1 29 + description: | 30 + This GPIO is optionally used to read the AC adapter status. This is a Host GPIO 31 + that is configured as an input and connected to the ACOK pin on the bq24735. 32 + Note: for backwards compatibility reasons, the GPIO must be active on AC adapter 33 + absence despite ACOK being active (high) on AC adapter presence. 34 + 35 + ti,charge-current: 36 + $ref: /schemas/types.yaml#/definitions/uint32 37 + description: | 38 + Used to control and set the charging current. 39 + This value must be between 128mA and 8.128A with a 64mA step resolution. 40 + The POR value is 0x0000h. This number is in mA (e.g. 8192). 41 + See spec for more information about the ChargeCurrent (0x14h) register. 42 + 43 + ti,charge-voltage: 44 + $ref: /schemas/types.yaml#/definitions/uint32 45 + description: | 46 + Used to control and set the charging voltage. 47 + This value must be between 1.024V and 19.2V with a 16mV step resolution. 48 + The POR value is 0x0000h. This number is in mV (e.g. 19200). 49 + See spec for more information about the ChargeVoltage (0x15h) register. 50 + 51 + ti,input-current: 52 + $ref: /schemas/types.yaml#/definitions/uint32 53 + description: | 54 + Used to control and set the charger input current. 55 + This value must be between 128mA and 8.064A with a 128mA step resolution. 56 + The POR value is 0x1000h. This number is in mA (e.g. 8064). 57 + See the spec for more information about the InputCurrent (0x3fh) register. 58 + 59 + ti,external-control: 60 + type: boolean 61 + description: | 62 + Indicates that the charger is configured externally and that the host should not 63 + attempt to enable/disable charging or set the charge voltage/current. 64 + 65 + poll-interval: 66 + $ref: /schemas/types.yaml#/definitions/uint32 67 + description: | 68 + If 'interrupts' is not specified, poll AC adapter presence with this interval (milliseconds). 69 + 70 + required: 71 + - compatible 72 + - reg 73 + 74 + additionalProperties: false 75 + 76 + examples: 77 + - | 78 + #include <dt-bindings/gpio/gpio.h> 79 + 80 + i2c0 { 81 + #address-cells = <1>; 82 + #size-cells = <0>; 83 + 84 + charger@9 { 85 + compatible = "ti,bq24735"; 86 + reg = <0x9>; 87 + ti,ac-detect-gpios = <&gpio 72 0x1>; 88 + }; 89 + };
-60
Documentation/devicetree/bindings/power/supply/bq25890.txt
··· 1 - Binding for TI bq25890 Li-Ion Charger 2 - 3 - This driver will support the bq25892, the bq25896 and the bq25890. There are 4 - other ICs in the same family but those have not been tested. 5 - 6 - Required properties: 7 - - compatible: Should contain one of the following: 8 - * "ti,bq25890" 9 - * "ti,bq25892" 10 - * "ti,bq25895" 11 - * "ti,bq25896" 12 - - reg: integer, i2c address of the device. 13 - - interrupts: interrupt line; 14 - - ti,battery-regulation-voltage: integer, maximum charging voltage (in uV); 15 - - ti,charge-current: integer, maximum charging current (in uA); 16 - - ti,termination-current: integer, charge will be terminated when current in 17 - constant-voltage phase drops below this value (in uA); 18 - - ti,precharge-current: integer, maximum charge current during precharge 19 - phase (in uA); 20 - - ti,minimum-sys-voltage: integer, when battery is charging and it is below 21 - minimum system voltage, the system will be regulated above 22 - minimum-sys-voltage setting (in uV); 23 - - ti,boost-voltage: integer, VBUS voltage level in boost mode (in uV); 24 - - ti,boost-max-current: integer, maximum allowed current draw in boost mode 25 - (in uA). 26 - 27 - Optional properties: 28 - - ti,boost-low-freq: boolean, if present boost mode frequency will be 500kHz, 29 - otherwise 1.5MHz; 30 - - ti,use-ilim-pin: boolean, if present the ILIM resistor will be used and the 31 - input current will be the lower between the resistor setting and the IINLIM 32 - register setting; 33 - - ti,thermal-regulation-threshold: integer, temperature above which the charge 34 - current is lowered, to avoid overheating (in degrees Celsius). If omitted, 35 - the default setting will be used (120 degrees); 36 - - ti,ibatcomp-micro-ohms: integer, value of a resistor in series with 37 - the battery; 38 - - ti,ibatcomp-clamp-microvolt: integer, maximum charging voltage adjustment due 39 - to expected voltage drop on in-series resistor; 40 - 41 - Example: 42 - 43 - bq25890 { 44 - compatible = "ti,bq25890"; 45 - reg = <0x6a>; 46 - 47 - interrupt-parent = <&gpio1>; 48 - interrupts = <16 IRQ_TYPE_EDGE_FALLING>; 49 - 50 - ti,battery-regulation-voltage = <4200000>; 51 - ti,charge-current = <1000000>; 52 - ti,termination-current = <50000>; 53 - ti,precharge-current = <128000>; 54 - ti,minimum-sys-voltage = <3600000>; 55 - ti,boost-voltage = <5000000>; 56 - ti,boost-max-current = <1000000>; 57 - 58 - ti,use-ilim-pin; 59 - ti,thermal-regulation-threshold = <120>; 60 - };
+123
Documentation/devicetree/bindings/power/supply/bq25890.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/bq25890.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Binding for bq25890, bq25892, bq25895 and bq25896 Li-Ion Charger 9 + 10 + maintainers: 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - ti,bq25890 20 + - ti,bq25892 21 + - ti,bq25895 22 + - ti,bq25896 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + interrupts: 28 + maxItems: 1 29 + 30 + ti,battery-regulation-voltage: 31 + $ref: /schemas/types.yaml#/definitions/uint32 32 + description: maximum charging voltage (in uV) 33 + 34 + ti,charge-current: 35 + $ref: /schemas/types.yaml#/definitions/uint32 36 + description: maximum charging current (in uA) 37 + 38 + ti,termination-current: 39 + $ref: /schemas/types.yaml#/definitions/uint32 40 + description: | 41 + charge will be terminated when current in constant-voltage phase 42 + drops below this value (in uA) 43 + 44 + ti,precharge-current: 45 + $ref: /schemas/types.yaml#/definitions/uint32 46 + description: maximum charge current during precharge phase (in uA) 47 + 48 + ti,minimum-sys-voltage: 49 + $ref: /schemas/types.yaml#/definitions/uint32 50 + description: | 51 + when battery is charging and it is below minimum system voltage, 52 + the system will be regulated above minimum-sys-voltage setting (in uV) 53 + 54 + ti,boost-voltage: 55 + $ref: /schemas/types.yaml#/definitions/uint32 56 + description: VBUS voltage level in boost mode (in uV) 57 + 58 + ti,boost-max-current: 59 + $ref: /schemas/types.yaml#/definitions/uint32 60 + description: maximum allowed current draw in boost mode (in uA) 61 + 62 + ti,boost-low-freq: 63 + description: boost mode frequency will be 500kHz, otherwise 1.5MHz 64 + type: boolean 65 + 66 + ti,use-ilim-pin: 67 + description: | 68 + ILIM resistor will be used and the input current will be the lower 69 + between the resistor setting and the IINLIM register setting 70 + type: boolean 71 + 72 + ti,thermal-regulation-threshold: 73 + $ref: /schemas/types.yaml#/definitions/uint32 74 + description: | 75 + temperature above which the charge current is lowered, to avoid overheating 76 + (in degrees Celsius). If omitted, the default setting will be used (120 degrees) 77 + 78 + ti,ibatcomp-micro-ohms: 79 + description: value of a resistor in series with the battery (in Micro Ohms) 80 + 81 + ti,ibatcomp-clamp-microvolt: 82 + description: max. charging voltage adjustment due to expected voltage drop on in-series resistor 83 + 84 + required: 85 + - compatible 86 + - reg 87 + - interrupts 88 + - ti,battery-regulation-voltage 89 + - ti,charge-current 90 + - ti,termination-current 91 + - ti,precharge-current 92 + - ti,minimum-sys-voltage 93 + - ti,boost-voltage 94 + - ti,boost-max-current 95 + 96 + additionalProperties: false 97 + 98 + examples: 99 + - | 100 + #include <dt-bindings/interrupt-controller/irq.h> 101 + i2c0 { 102 + #address-cells = <1>; 103 + #size-cells = <0>; 104 + 105 + charger@6a { 106 + compatible = "ti,bq25890"; 107 + reg = <0x6a>; 108 + 109 + interrupt-parent = <&gpio1>; 110 + interrupts = <16 IRQ_TYPE_EDGE_FALLING>; 111 + 112 + ti,battery-regulation-voltage = <4200000>; 113 + ti,charge-current = <1000000>; 114 + ti,termination-current = <50000>; 115 + ti,precharge-current = <128000>; 116 + ti,minimum-sys-voltage = <3600000>; 117 + ti,boost-voltage = <5000000>; 118 + ti,boost-max-current = <1000000>; 119 + 120 + ti,use-ilim-pin; 121 + ti,thermal-regulation-threshold = <120>; 122 + }; 123 + };
+2 -1
Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
··· 52 52 - ti,bq27z561 53 53 - ti,bq28z610 54 54 - ti,bq34z100 55 + - ti,bq78z100 55 56 56 57 reg: 57 58 maxItems: 1 ··· 66 65 - charge-full-design-microamp-hours 67 66 - voltage-min-design-microvolt 68 67 Both or neither of the *-full-design-*-hours properties must be set. 69 - See Documentation/devicetree/bindings/power/supply/battery.txt 68 + See Documentation/devicetree/bindings/power/supply/battery.yaml 70 69 71 70 power-supplies: true 72 71
-31
Documentation/devicetree/bindings/power/supply/cpcap-battery.txt
··· 1 - Motorola CPCAP PMIC battery driver binding 2 - 3 - Required properties: 4 - - compatible: Shall be "motorola,cpcap-battery" 5 - - interrupts: Interrupt specifier for each name in interrupt-names 6 - - interrupt-names: Should contain the following entries: 7 - "lowbph", "lowbpl", "chrgcurr1", "battdetb" 8 - - io-channels: IIO ADC channel specifier for each name in io-channel-names 9 - - io-channel-names: Should contain the following entries: 10 - "battdetb", "battp", "chg_isense", "batti" 11 - - power-supplies: List of phandles for power-supplying devices, as 12 - described in power_supply.txt. Typically a reference 13 - to cpcap_charger. 14 - 15 - Example: 16 - 17 - cpcap_battery: battery { 18 - compatible = "motorola,cpcap-battery"; 19 - interrupts-extended = < 20 - &cpcap 5 0 &cpcap 3 0 21 - &cpcap 20 0 &cpcap 54 0 22 - >; 23 - interrupt-names = 24 - "lowbph", "lowbpl", 25 - "chrgcurr1", "battdetb"; 26 - io-channels = <&cpcap_adc 0 &cpcap_adc 1 27 - &cpcap_adc 5 &cpcap_adc 6>; 28 - io-channel-names = "battdetb", "battp", 29 - "chg_isense", "batti"; 30 - power-supplies = <&cpcap_charger>; 31 - };
+87
Documentation/devicetree/bindings/power/supply/cpcap-battery.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/cpcap-battery.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Motorola CPCAP PMIC battery 9 + 10 + maintainers: 11 + - Tony Lindgren <tony@atomide.com> 12 + - Sebastian Reichel <sre@kernel.org> 13 + 14 + description: | 15 + Motorola CPCAP is a PMIC found in some mobile phones, e.g. 16 + the Droid 4. This binding describes its battery fuel gauge 17 + sub-function. 18 + 19 + allOf: 20 + - $ref: power-supply.yaml# 21 + 22 + properties: 23 + compatible: 24 + const: motorola,cpcap-battery 25 + 26 + interrupts: 27 + items: 28 + - description: eol interrupt 29 + - description: low battery percentage interrupt 30 + - description: critical battery percentage interrupt 31 + - description: charger detect interrupt 32 + - description: battery detect interrupt 33 + - description: coulomb counter calibration interrupt 34 + 35 + interrupt-names: 36 + items: 37 + - const: eol 38 + - const: lowbph 39 + - const: lowbpl 40 + - const: chrgcurr1 41 + - const: battdetb 42 + - const: cccal 43 + 44 + io-channels: 45 + items: 46 + - description: battery temperature 47 + - description: battery voltage 48 + - description: battery charge current 49 + - description: battery current 50 + 51 + io-channel-names: 52 + items: 53 + - const: battdetb 54 + - const: battp 55 + - const: chg_isense 56 + - const: batti 57 + 58 + power-supplies: true 59 + 60 + required: 61 + - compatible 62 + - interrupts 63 + - interrupt-names 64 + - io-channels 65 + - io-channel-names 66 + - power-supplies 67 + 68 + additionalProperties: false 69 + 70 + examples: 71 + - | 72 + cpcap { 73 + battery { 74 + compatible = "motorola,cpcap-battery"; 75 + interrupts-extended = 76 + <&cpcap 6 0>, <&cpcap 5 0>, <&cpcap 3 0>, 77 + <&cpcap 20 0>, <&cpcap 54 0>, <&cpcap 57 0>; 78 + interrupt-names = 79 + "eol", "lowbph", "lowbpl", 80 + "chrgcurr1", "battdetb", "cccal"; 81 + io-channels = <&cpcap_adc 0>, <&cpcap_adc 1>, 82 + <&cpcap_adc 5>, <&cpcap_adc 6>; 83 + io-channel-names = "battdetb", "battp", 84 + "chg_isense", "batti"; 85 + power-supplies = <&cpcap_charger>; 86 + }; 87 + };
-40
Documentation/devicetree/bindings/power/supply/cpcap-charger.txt
··· 1 - Motorola CPCAP PMIC battery charger binding 2 - 3 - Required properties: 4 - - compatible: Shall be "motorola,mapphone-cpcap-charger" 5 - - interrupts: Interrupt specifier for each name in interrupt-names 6 - - interrupt-names: Should contain the following entries: 7 - "chrg_det", "rvrs_chrg", "chrg_se1b", "se0conn", 8 - "rvrs_mode", "chrgcurr2", "chrgcurr1", "vbusvld", 9 - "battdetb" 10 - - io-channels: IIO ADC channel specifier for each name in io-channel-names 11 - - io-channel-names: Should contain the following entries: 12 - "battdetb", "battp", "vbus", "chg_isense", "batti" 13 - 14 - Optional properties: 15 - - mode-gpios: Optionally CPCAP charger can have a companion wireless 16 - charge controller that is controlled with two GPIOs 17 - that are active low. 18 - 19 - Example: 20 - 21 - cpcap_charger: charger { 22 - compatible = "motorola,mapphone-cpcap-charger"; 23 - interrupts-extended = < 24 - &cpcap 13 0 &cpcap 12 0 &cpcap 29 0 &cpcap 28 0 25 - &cpcap 22 0 &cpcap 21 0 &cpcap 20 0 &cpcap 19 0 26 - &cpcap 54 0 27 - >; 28 - interrupt-names = 29 - "chrg_det", "rvrs_chrg", "chrg_se1b", "se0conn", 30 - "rvrs_mode", "chrgcurr2", "chrgcurr1", "vbusvld", 31 - "battdetb"; 32 - mode-gpios = <&gpio3 29 GPIO_ACTIVE_LOW 33 - &gpio3 23 GPIO_ACTIVE_LOW>; 34 - io-channels = <&cpcap_adc 0 &cpcap_adc 1 35 - &cpcap_adc 2 &cpcap_adc 5 36 - &cpcap_adc 6>; 37 - io-channel-names = "battdetb", "battp", 38 - "vbus", "chg_isense", 39 - "batti"; 40 - };
+106
Documentation/devicetree/bindings/power/supply/cpcap-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/cpcap-charger.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Motorola CPCAP PMIC charger 9 + 10 + maintainers: 11 + - Tony Lindgren <tony@atomide.com> 12 + - Sebastian Reichel <sre@kernel.org> 13 + 14 + description: | 15 + Motorola CPCAP is a PMIC found in some mobile phones, e.g. 16 + the Droid 4. This binding describes its battery charger 17 + sub-function. 18 + 19 + allOf: 20 + - $ref: power-supply.yaml# 21 + 22 + properties: 23 + compatible: 24 + const: motorola,mapphone-cpcap-charger 25 + 26 + interrupts: 27 + items: 28 + - description: charger detection interrupt 29 + - description: reverse charge interrupt 30 + - description: SE1 charger detection interrupt 31 + - description: SE0 charger detection interrupt 32 + - description: reverse mode interrupt 33 + - description: charge current 2 interrupt 34 + - description: charge current 1 interrupt 35 + - description: VBUS valid interrupt 36 + - description: battery detect interrupt 37 + 38 + interrupt-names: 39 + items: 40 + - const: chrg_det 41 + - const: rvrs_chrg 42 + - const: chrg_se1b 43 + - const: se0conn 44 + - const: rvrs_mode 45 + - const: chrgcurr2 46 + - const: chrgcurr1 47 + - const: vbusvld 48 + - const: battdetb 49 + 50 + io-channels: 51 + items: 52 + - description: battery temperature 53 + - description: battery voltage 54 + - description: VBUS voltage 55 + - description: battery charge current 56 + - description: battery current 57 + 58 + io-channel-names: 59 + items: 60 + - const: battdetb 61 + - const: battp 62 + - const: vbus 63 + - const: chg_isense 64 + - const: batti 65 + 66 + mode-gpios: 67 + description: | 68 + Optionally CPCAP charger can have a companion wireless 69 + charge controller that is controlled with two GPIOs 70 + that are active low. 71 + minItems: 2 72 + maxItems: 2 73 + 74 + required: 75 + - compatible 76 + - interrupts 77 + - interrupt-names 78 + - io-channels 79 + - io-channel-names 80 + 81 + additionalProperties: false 82 + 83 + examples: 84 + - | 85 + #include <dt-bindings/gpio/gpio.h> 86 + cpcap { 87 + charger { 88 + compatible = "motorola,mapphone-cpcap-charger"; 89 + interrupts-extended = 90 + <&cpcap 13 0>, <&cpcap 12 0>, <&cpcap 29 0>, <&cpcap 28 0>, 91 + <&cpcap 22 0>, <&cpcap 21 0>, <&cpcap 20 0>, <&cpcap 19 0>, 92 + <&cpcap 54 0>; 93 + interrupt-names = 94 + "chrg_det", "rvrs_chrg", "chrg_se1b", "se0conn", 95 + "rvrs_mode", "chrgcurr2", "chrgcurr1", "vbusvld", 96 + "battdetb"; 97 + mode-gpios = <&gpio3 29 GPIO_ACTIVE_LOW>, 98 + <&gpio3 23 GPIO_ACTIVE_LOW>; 99 + io-channels = <&cpcap_adc 0>, <&cpcap_adc 1>, 100 + <&cpcap_adc 2>, <&cpcap_adc 5>, 101 + <&cpcap_adc 6>; 102 + io-channel-names = "battdetb", "battp", 103 + "vbus", "chg_isense", 104 + "batti"; 105 + }; 106 + };
-26
Documentation/devicetree/bindings/power/supply/da9150-charger.txt
··· 1 - Dialog Semiconductor DA9150 Charger Power Supply bindings 2 - 3 - Required properties: 4 - - compatible: "dlg,da9150-charger" for DA9150 Charger Power Supply 5 - 6 - Optional properties: 7 - - io-channels: List of phandle and IIO specifier pairs 8 - - io-channel-names: List of channel names used by charger 9 - ["CHAN_IBUS", "CHAN_VBUS", "CHAN_TJUNC", "CHAN_VBAT"] 10 - (See Documentation/devicetree/bindings/iio/iio-bindings.txt for further info) 11 - 12 - 13 - Example: 14 - 15 - da9150-charger { 16 - compatible = "dlg,da9150-charger"; 17 - 18 - io-channels = <&gpadc 0>, 19 - <&gpadc 2>, 20 - <&gpadc 8>, 21 - <&gpadc 5>; 22 - io-channel-names = "CHAN_IBUS", 23 - "CHAN_VBUS", 24 - "CHAN_TJUNC", 25 - "CHAN_VBAT"; 26 - };
-23
Documentation/devicetree/bindings/power/supply/da9150-fg.txt
··· 1 - Dialog Semiconductor DA9150 Fuel-Gauge Power Supply bindings 2 - 3 - Required properties: 4 - - compatible: "dlg,da9150-fuel-gauge" for DA9150 Fuel-Gauge Power Supply 5 - 6 - Optional properties: 7 - - dlg,update-interval: Interval time (milliseconds) between battery level checks. 8 - - dlg,warn-soc-level: Battery discharge level (%) where warning event raised. 9 - [1 - 100] 10 - - dlg,crit-soc-level: Battery discharge level (%) where critical event raised. 11 - This value should be lower than the warning level. 12 - [1 - 100] 13 - 14 - 15 - Example: 16 - 17 - fuel-gauge { 18 - compatible = "dlg,da9150-fuel-gauge"; 19 - 20 - dlg,update-interval = <10000>; 21 - dlg,warn-soc-level = /bits/ 8 <15>; 22 - dlg,crit-soc-level = /bits/ 8 <5>; 23 - };
+52
Documentation/devicetree/bindings/power/supply/dlg,da9150-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/dlg,da9150-charger.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Dialog Semiconductor DA9150 Charger Power Supply bindings 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: dlg,da9150-charger 18 + 19 + io-channels: 20 + items: 21 + - description: ADC channel for current 22 + - description: ADC channel for bus voltage 23 + - description: ADC channel for junction temperature 24 + - description: ADC channel for battery voltage 25 + 26 + io-channel-names: 27 + items: 28 + - const: CHAN_IBUS 29 + - const: CHAN_VBUS 30 + - const: CHAN_TJUNC 31 + - const: CHAN_VBAT 32 + 33 + required: 34 + - compatible 35 + 36 + additionalProperties: false 37 + 38 + examples: 39 + - | 40 + pmic { 41 + charger { 42 + compatible = "dlg,da9150-charger"; 43 + io-channels = <&gpadc 0>, 44 + <&gpadc 2>, 45 + <&gpadc 8>, 46 + <&gpadc 5>; 47 + io-channel-names = "CHAN_IBUS", 48 + "CHAN_VBUS", 49 + "CHAN_TJUNC", 50 + "CHAN_VBAT"; 51 + }; 52 + };
+51
Documentation/devicetree/bindings/power/supply/dlg,da9150-fuel-gauge.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/dlg,da9150-fuel-gauge.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Dialog Semiconductor DA9150 Fuel-Gauge Power Supply bindings 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: dlg,da9150-fuel-gauge 18 + 19 + dlg,update-interval: 20 + $ref: /schemas/types.yaml#/definitions/uint32 21 + description: Interval time (milliseconds) between battery level checks. 22 + 23 + dlg,warn-soc-level: 24 + $ref: /schemas/types.yaml#/definitions/uint8 25 + minimum: 1 26 + maximum: 100 27 + description: Battery discharge level (%) where warning event raised. 28 + 29 + dlg,crit-soc-level: 30 + $ref: /schemas/types.yaml#/definitions/uint8 31 + minimum: 1 32 + maximum: 100 33 + description: | 34 + Battery discharge level (%) where critical event raised. 35 + This value should be lower than the warning level. 36 + 37 + required: 38 + - compatible 39 + 40 + additionalProperties: false 41 + 42 + examples: 43 + - | 44 + pmic { 45 + battery { 46 + compatible = "dlg,da9150-fuel-gauge"; 47 + dlg,update-interval = <10000>; 48 + dlg,warn-soc-level = /bits/ 8 <15>; 49 + dlg,crit-soc-level = /bits/ 8 <5>; 50 + }; 51 + };
-17
Documentation/devicetree/bindings/power/supply/isp1704.txt
··· 1 - Binding for NXP ISP1704 USB Charger Detection 2 - 3 - Required properties: 4 - - compatible: Should contain one of the following: 5 - * "nxp,isp1704" 6 - - nxp,enable-gpio: Should contain a phandle + gpio-specifier 7 - to the GPIO pin connected to the chip's enable pin. 8 - - usb-phy: Should contain a phandle to the USB PHY 9 - the ISP1704 is connected to. 10 - 11 - Example: 12 - 13 - isp1704 { 14 - compatible = "nxp,isp1704"; 15 - nxp,enable-gpio = <&gpio3 3 GPIO_ACTIVE_LOW>; 16 - usb-phy = <&usb2_phy>; 17 - };
+42
Documentation/devicetree/bindings/power/supply/isp1704.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/isp1704.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Binding for NXP ISP1704 USB Charger Detection 9 + 10 + maintainers: 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + const: nxp,isp1704 19 + 20 + nxp,enable-gpio: 21 + maxItems: 1 22 + description: GPIO connected to the chip's enable pin 23 + 24 + usb-phy: 25 + $ref: /schemas/types.yaml#/definitions/phandle 26 + description: USB PHY the ISP1704 is connected to 27 + 28 + required: 29 + - compatible 30 + - nxp,enable-gpio 31 + - usb-phy 32 + 33 + additionalProperties: false 34 + 35 + examples: 36 + - | 37 + #include <dt-bindings/gpio/gpio.h> 38 + charger-detect { 39 + compatible = "nxp,isp1704"; 40 + nxp,enable-gpio = <&gpio3 3 GPIO_ACTIVE_LOW>; 41 + usb-phy = <&usb2_phy>; 42 + };
+55
Documentation/devicetree/bindings/power/supply/lego,ev3-battery.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/lego,ev3-battery.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: LEGO MINDSTORMS EV3 Battery 8 + 9 + maintainers: 10 + - David Lechner <david@lechnology.com> 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + description: | 14 + LEGO MINDSTORMS EV3 has some built-in capability for monitoring the battery. 15 + It uses 6 AA batteries or a special Li-ion rechargeable battery pack that is 16 + detected by a key switch in the battery compartment. 17 + 18 + allOf: 19 + - $ref: power-supply.yaml# 20 + 21 + properties: 22 + compatible: 23 + const: lego,ev3-battery 24 + 25 + io-channels: 26 + items: 27 + - description: ADC channel for battery voltage 28 + - description: ADC channel for battery current 29 + 30 + io-channel-names: 31 + items: 32 + - const: voltage 33 + - const: current 34 + 35 + rechargeable-gpios: 36 + maxItems: 1 37 + description: Rechargeable battery indication gpio 38 + 39 + required: 40 + - compatible 41 + - io-channels 42 + - io-channel-names 43 + - rechargeable-gpios 44 + 45 + additionalProperties: false 46 + 47 + examples: 48 + - | 49 + #include <dt-bindings/gpio/gpio.h> 50 + battery { 51 + compatible = "lego,ev3-battery"; 52 + io-channels = <&adc 4>, <&adc 3>; 53 + io-channel-names = "voltage", "current"; 54 + rechargeable-gpios = <&gpio 136 GPIO_ACTIVE_LOW>; 55 + };
-21
Documentation/devicetree/bindings/power/supply/lego_ev3_battery.txt
··· 1 - LEGO MINDSTORMS EV3 Battery 2 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 - 4 - LEGO MINDSTORMS EV3 has some built-in capability for monitoring the battery. 5 - It uses 6 AA batteries or a special Li-ion rechargeable battery pack that is 6 - detected by a key switch in the battery compartment. 7 - 8 - Required properties: 9 - - compatible: Must be "lego,ev3-battery" 10 - - io-channels: phandles to analog inputs for reading voltage and current 11 - - io-channel-names: Must be "voltage", "current" 12 - - rechargeable-gpios: phandle to the rechargeable battery indication gpio 13 - 14 - Example: 15 - 16 - battery { 17 - compatible = "lego,ev3-battery"; 18 - io-channels = <&adc 4>, <&adc 3>; 19 - io-channel-names = "voltage", "current"; 20 - rechargeable-gpios = <&gpio 136 GPIO_ACTIVE_LOW>; 21 - };
+44
Documentation/devicetree/bindings/power/supply/lltc,lt3651-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/lltc,lt3651-charger.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Analog Devices LT3651 Charger Power Supply bindings 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + enum: 18 + - lltc,lt3651-charger 19 + - lltc,ltc3651-charger # deprecated, use lltc,lt3651-charger 20 + 21 + lltc,acpr-gpios: 22 + maxItems: 1 23 + 24 + lltc,fault-gpios: 25 + maxItems: 1 26 + 27 + lltc,chrg-gpios: 28 + maxItems: 1 29 + 30 + required: 31 + - compatible 32 + - lltc,acpr-gpios 33 + 34 + additionalProperties: false 35 + 36 + examples: 37 + - | 38 + #include <dt-bindings/gpio/gpio.h> 39 + charger { 40 + compatible = "lltc,lt3651-charger"; 41 + lltc,acpr-gpios = <&gpio0 68 GPIO_ACTIVE_LOW>; 42 + lltc,fault-gpios = <&gpio0 64 GPIO_ACTIVE_LOW>; 43 + lltc,chrg-gpios = <&gpio0 63 GPIO_ACTIVE_LOW>; 44 + };
+66
Documentation/devicetree/bindings/power/supply/lltc,ltc294x.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/lltc,ltc294x.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Binding for LTC2941, LTC2942, LTC2943 and LTC2944 battery fuel gauges 8 + 9 + description: | 10 + All chips measure battery capacity. 11 + The LTC2942 is pin compatible with the LTC2941, it adds voltage and 12 + temperature monitoring, and is runtime detected. LTC2943 and LTC2944 13 + are software compatible, uses a slightly different conversion formula 14 + for the charge counter and adds voltage, current and temperature monitoring. 15 + 16 + maintainers: 17 + - Sebastian Reichel <sre@kernel.org> 18 + 19 + allOf: 20 + - $ref: power-supply.yaml# 21 + 22 + properties: 23 + compatible: 24 + enum: 25 + - lltc,ltc2941 26 + - lltc,ltc2942 27 + - lltc,ltc2943 28 + - lltc,ltc2944 29 + 30 + reg: 31 + maxItems: 1 32 + 33 + lltc,resistor-sense: 34 + $ref: /schemas/types.yaml#/definitions/int32 35 + description: | 36 + Sense resistor value in milli-ohms. 37 + Can be negative value when the battery has been connected to the wrong end of the resistor. 38 + 39 + lltc,prescaler-exponent: 40 + $ref: /schemas/types.yaml#/definitions/uint32 41 + description: | 42 + The prescaler exponent as explained in the datasheet. 43 + This determines the range and accuracy of the gauge. 44 + The value is programmed into the chip only if it differs from the current setting. 45 + The setting is lost when the battery is disconnected. 46 + 47 + required: 48 + - compatible 49 + - reg 50 + - lltc,resistor-sense 51 + - lltc,prescaler-exponent 52 + 53 + additionalProperties: false 54 + 55 + examples: 56 + - | 57 + i2c0 { 58 + #address-cells = <1>; 59 + #size-cells = <0>; 60 + battery@64 { 61 + compatible = "lltc,ltc2943"; 62 + reg = <0x64>; 63 + lltc,resistor-sense = <15>; 64 + lltc,prescaler-exponent = <5>; /* 2^(2*5) = 1024 */ 65 + }; 66 + };
-43
Documentation/devicetree/bindings/power/supply/lp8727_charger.txt
··· 1 - Binding for TI/National Semiconductor LP8727 Charger 2 - 3 - Required properties: 4 - - compatible: "ti,lp8727" 5 - - reg: I2C slave address 27h 6 - 7 - Optional properties: 8 - - interrupts: interrupt specifier (see interrupt binding[0]) 9 - - debounce-ms: interrupt debounce time. (u32) 10 - 11 - AC and USB charging parameters 12 - - charger-type: "ac" or "usb" (string) 13 - - eoc-level: value of 'enum lp8727_eoc_level' (u8) 14 - - charging-current: value of 'enum lp8727_ichg' (u8) 15 - 16 - [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt 17 - 18 - Example) 19 - 20 - lp8727@27 { 21 - compatible = "ti,lp8727"; 22 - reg = <0x27>; 23 - 24 - /* GPIO 134 is used for LP8728 interrupt pin */ 25 - interrupt-parent = <&gpio5>; /* base = 128 */ 26 - interrupts = <6 0x2>; /* offset = 6, falling edge type */ 27 - 28 - debounce-ms = <300>; 29 - 30 - /* AC charger: 5% EOC and 500mA charging current */ 31 - ac { 32 - charger-type = "ac"; 33 - eoc-level = /bits/ 8 <0>; 34 - charging-current = /bits/ 8 <4>; 35 - }; 36 - 37 - /* USB charger: 10% EOC and 400mA charging current */ 38 - usb { 39 - charger-type = "usb"; 40 - eoc-level = /bits/ 8 <1>; 41 - charging-current = /bits/ 8 <2>; 42 - }; 43 - };
-29
Documentation/devicetree/bindings/power/supply/lt3651-charger.txt
··· 1 - Analog Devices LT3651 Charger Power Supply bindings: lt3651-charger 2 - 3 - Required properties: 4 - - compatible: Should contain one of the following: 5 - * "lltc,ltc3651-charger", (DEPRECATED: Use "lltc,lt3651-charger") 6 - * "lltc,lt3651-charger" 7 - - lltc,acpr-gpios: Connect to ACPR output. See remark below. 8 - 9 - Optional properties: 10 - - lltc,fault-gpios: Connect to FAULT output. See remark below. 11 - - lltc,chrg-gpios: Connect to CHRG output. See remark below. 12 - 13 - The lt3651 outputs are open-drain type and active low. The driver assumes the 14 - GPIO reports "active" when the output is asserted, so if the pins have been 15 - connected directly, the GPIO flags should be set to active low also. 16 - 17 - The driver will attempt to aquire interrupts for all GPIOs to detect changes in 18 - line state. If the system is not capabale of providing interrupts, the driver 19 - cannot report changes and userspace will need to periodically read the sysfs 20 - attributes to detect changes. 21 - 22 - Example: 23 - 24 - charger: battery-charger { 25 - compatible = "lltc,lt3651-charger"; 26 - lltc,acpr-gpios = <&gpio0 68 GPIO_ACTIVE_LOW>; 27 - lltc,fault-gpios = <&gpio0 64 GPIO_ACTIVE_LOW>; 28 - lltc,chrg-gpios = <&gpio0 63 GPIO_ACTIVE_LOW>; 29 - };
-28
Documentation/devicetree/bindings/power/supply/ltc2941.txt
··· 1 - binding for LTC2941, LTC2942, LTC2943 and LTC2944 battery gauges 2 - 3 - All chips measure battery capacity. 4 - The LTC2942 is pin compatible with the LTC2941, it adds voltage and 5 - temperature monitoring, and is runtime detected. LTC2943 and LTC2944 6 - is software compatible, uses a slightly different conversion formula 7 - for the charge counter and adds voltage, current and temperature monitoring. 8 - 9 - Required properties: 10 - - compatible: Should contain "lltc,ltc2941", "lltc,ltc2942", "lltc,ltc2943" 11 - or "lltc,ltc2944" which also indicates the type of I2C chip attached. 12 - - reg: The 7-bit I2C address. 13 - - lltc,resistor-sense: The sense resistor value in milli-ohms. Can be a 32-bit 14 - negative value when the battery has been connected to the wrong end of the 15 - resistor. 16 - - lltc,prescaler-exponent: The prescaler exponent as explained in the datasheet. 17 - This determines the range and accuracy of the gauge. The value is programmed 18 - into the chip only if it differs from the current setting. The setting is 19 - lost when the battery is disconnected. 20 - 21 - Example from the Topic Miami Florida board: 22 - 23 - fuelgauge: ltc2943@64 { 24 - compatible = "lltc,ltc2943"; 25 - reg = <0x64>; 26 - lltc,resistor-sense = <15>; 27 - lltc,prescaler-exponent = <5>; /* 2^(2*5) = 1024 */ 28 - };
-52
Documentation/devicetree/bindings/power/supply/max17040_battery.txt
··· 1 - max17040_battery 2 - ~~~~~~~~~~~~~~~~ 3 - 4 - Required properties : 5 - - compatible : "maxim,max17040", "maxim,max17041", "maxim,max17043", 6 - "maxim,max17044", "maxim,max17048", "maxim,max17049", 7 - "maxim,max17058", "maxim,max17059" or "maxim,max77836-battery" 8 - - reg: i2c slave address 9 - 10 - Optional properties : 11 - - maxim,alert-low-soc-level : The alert threshold that sets the state of 12 - charge level (%) where an interrupt is 13 - generated. Can be configured from 1 up to 32 14 - (%). If skipped the power up default value of 15 - 4 (%) will be used. 16 - - maxim,double-soc : Certain devices return double the capacity. 17 - Specify this boolean property to divide the 18 - reported value in 2 and thus normalize it. 19 - SOC == State of Charge == Capacity. 20 - - maxim,rcomp : A value to compensate readings for various 21 - battery chemistries and operating temperatures. 22 - max17040,41 have 2 byte rcomp, default to 23 - 0x97 0x00. All other devices have one byte 24 - rcomp, default to 0x97. 25 - - interrupts : Interrupt line see Documentation/devicetree/ 26 - bindings/interrupt-controller/interrupts.txt 27 - - wakeup-source : This device has wakeup capabilities. Use this 28 - property to use alert low SOC level interrupt 29 - as wake up source. 30 - 31 - Optional properties support interrupt functionality for alert low state of 32 - charge level, present in some ICs in the same family, and should be used with 33 - compatible "maxim,max77836-battery". 34 - 35 - Example: 36 - 37 - battery-fuel-gauge@36 { 38 - compatible = "maxim,max77836-battery"; 39 - reg = <0x36>; 40 - maxim,alert-low-soc-level = <10>; 41 - interrupt-parent = <&gpio7>; 42 - interrupts = <2 IRQ_TYPE_EDGE_FALLING>; 43 - wakeup-source; 44 - }; 45 - 46 - battery-fuel-gauge@36 { 47 - compatible = "maxim,max17048"; 48 - reg = <0x36>; 49 - maxim,rcomp = /bits/ 8 <0x56>; 50 - maxim,alert-low-soc-level = <10>; 51 - maxim,double-soc; 52 - };
-35
Documentation/devicetree/bindings/power/supply/max17042_battery.txt
··· 1 - max17042_battery 2 - ~~~~~~~~~~~~~~~~ 3 - 4 - Required properties : 5 - - compatible : one of the following 6 - * "maxim,max17042" 7 - * "maxim,max17047" 8 - * "maxim,max17050" 9 - * "maxim,max17055" 10 - 11 - Optional properties : 12 - - maxim,rsns-microohm : Resistance of rsns resistor in micro Ohms 13 - (datasheet-recommended value is 10000). 14 - Defining this property enables current-sense functionality. 15 - 16 - Optional threshold properties : 17 - If skipped the condition won't be reported. 18 - - maxim,cold-temp : Temperature threshold to report battery 19 - as cold (in tenths of degree Celsius). 20 - - maxim,over-heat-temp : Temperature threshold to report battery 21 - as over heated (in tenths of degree Celsius). 22 - - maxim,dead-volt : Voltage threshold to report battery 23 - as dead (in mV). 24 - - maxim,over-volt : Voltage threshold to report battery 25 - as over voltage (in mV). 26 - 27 - Example: 28 - 29 - battery-charger@36 { 30 - compatible = "maxim,max17042"; 31 - reg = <0x36>; 32 - maxim,rsns-microohm = <10000>; 33 - maxim,over-heat-temp = <600>; 34 - maxim,over-volt = <4300>; 35 - };
-24
Documentation/devicetree/bindings/power/supply/max8903-charger.txt
··· 1 - Maxim Semiconductor MAX8903 Battery Charger bindings 2 - 3 - Required properties: 4 - - compatible: "maxim,max8903" for MAX8903 Battery Charger 5 - - dok-gpios: Valid DC power has been detected (active low, input), optional if uok-gpios is provided 6 - - uok-gpios: Valid USB power has been detected (active low, input), optional if dok-gpios is provided 7 - 8 - Optional properties: 9 - - cen-gpios: Charge enable pin (active low, output) 10 - - chg-gpios: Charger status pin (active low, input) 11 - - flt-gpios: Fault pin (active low, output) 12 - - dcm-gpios: Current limit mode setting (DC=1 or USB=0, output) 13 - - usus-gpios: USB suspend pin (active high, output) 14 - 15 - 16 - Example: 17 - 18 - max8903-charger { 19 - compatible = "maxim,max8903"; 20 - dok-gpios = <&gpio2 3 GPIO_ACTIVE_LOW>; 21 - flt-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>; 22 - chg-gpios = <&gpio3 15 GPIO_ACTIVE_LOW>; 23 - cen-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>; 24 - };
-26
Documentation/devicetree/bindings/power/supply/maxim,ds2760.txt
··· 1 - Devicetree bindings for Maxim DS2760 2 - ==================================== 3 - 4 - The ds2760 is a w1 slave device and must hence have its sub-node in DT 5 - under a w1 bus master node. 6 - 7 - The device exposes a power supply, so the details described in 8 - Documentation/devicetree/bindings/power/supply/power_supply.txt apply. 9 - 10 - Required properties: 11 - - compatible: must be "maxim,ds2760" 12 - 13 - Optional properties: 14 - - power-supplies: Refers to one or more power supplies connected to 15 - this battery. 16 - - maxim,pmod-enabled: This boolean property enables the DS2760 to enter 17 - sleep mode when the DQ line goes low for greater 18 - than 2 seconds and leave sleep Mode when the DQ 19 - line goes high. 20 - - maxim,cache-time-ms: Time im milliseconds to cache the data for. When 21 - this time expires, the values are read again from 22 - the hardware. Defaults to 1000. 23 - - rated-capacity-microamp-hours: 24 - The rated capacity of the battery, in mAh. 25 - If not specified, the value stored in the 26 - non-volatile chip memory is used.
+43
Documentation/devicetree/bindings/power/supply/maxim,ds2760.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/maxim,ds2760.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Maxim DS2760 DT bindings 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + description: | 13 + The ds2760 is a w1 slave device and must hence have its sub-node in 14 + DT under a w1 bus master node. 15 + 16 + allOf: 17 + - $ref: power-supply.yaml# 18 + 19 + properties: 20 + compatible: 21 + const: maxim,ds2760 22 + 23 + maxim,pmod-enabled: 24 + description: | 25 + Allow the DS2760 to enter sleep mode when the DQ line goes low for more than 2 seconds 26 + and leave sleep Mode when the DQ line goes high. 27 + type: boolean 28 + 29 + maxim,cache-time-ms: 30 + description: | 31 + Time im milliseconds to cache the data for. 32 + When this time expires, the values are read again from the hardware. 33 + Defaults to 1000. 34 + 35 + rated-capacity-microamp-hours: 36 + description: | 37 + The rated capacity of the battery, in mAh. 38 + If not specified, the value stored in the non-volatile chip memory is used. 39 + 40 + required: 41 + - compatible 42 + 43 + unevaluatedProperties: false
-23
Documentation/devicetree/bindings/power/supply/maxim,max14656.txt
··· 1 - Maxim MAX14656 / AL32 USB Charger Detector 2 - 3 - Required properties : 4 - - compatible : "maxim,max14656"; 5 - - reg: i2c slave address 6 - - interrupts: interrupt line 7 - 8 - Example: 9 - 10 - &i2c2 { 11 - clock-frequency = <50000>; 12 - pinctrl-names = "default"; 13 - pinctrl-0 = <&pinctrl_i2c2>; 14 - 15 - max14656@35 { 16 - compatible = "maxim,max14656"; 17 - reg = <0x35>; 18 - pinctrl-names = "default"; 19 - pinctrl-0 = <&pinctrl_charger_detect>; 20 - interrupt-parent = <&gpio6>; 21 - interrupts = <26 IRQ_TYPE_LEVEL_HIGH>; 22 - }; 23 - };
+45
Documentation/devicetree/bindings/power/supply/maxim,max14656.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/maxim,max14656.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Maxim MAX14656 DT bindings 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: maxim,max14656 18 + 19 + reg: 20 + maxItems: 1 21 + 22 + interrupts: 23 + maxItems: 1 24 + 25 + required: 26 + - compatible 27 + - reg 28 + - interrupts 29 + 30 + additionalProperties: false 31 + 32 + examples: 33 + - | 34 + #include <dt-bindings/interrupt-controller/irq.h> 35 + i2c0 { 36 + #address-cells = <1>; 37 + #size-cells = <0>; 38 + 39 + charger-detector@35 { 40 + compatible = "maxim,max14656"; 41 + reg = <0x35>; 42 + interrupt-parent = <&gpio6>; 43 + interrupts = <26 IRQ_TYPE_LEVEL_HIGH>; 44 + }; 45 + };
+95
Documentation/devicetree/bindings/power/supply/maxim,max17040.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/maxim,max17040.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Maxim 17040 fuel gauge series 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + enum: 18 + - maxim,max17040 19 + - maxim,max17041 20 + - maxim,max17043 21 + - maxim,max17044 22 + - maxim,max17048 23 + - maxim,max17049 24 + - maxim,max17058 25 + - maxim,max17059 26 + - maxim,max77836-battery 27 + 28 + reg: 29 + maxItems: 1 30 + 31 + maxim,alert-low-soc-level: 32 + $ref: /schemas/types.yaml#/definitions/uint32 33 + minimum: 1 34 + maximum: 32 35 + description: | 36 + The alert threshold that sets the state of charge level (%) where an interrupt is generated. 37 + If skipped the power up default value of 4 (%) will be used. 38 + 39 + maxim,double-soc: 40 + type: boolean 41 + description: | 42 + Certain devices return double the capacity. 43 + Specify this to divide the reported value in 2 and thus normalize it. 44 + SoC == State of Charge == Capacity. 45 + 46 + maxim,rcomp: 47 + $ref: /schemas/types.yaml#/definitions/uint32 48 + description: | 49 + A value to compensate readings for various battery chemistries and operating temperatures. 50 + max17040,41 have 2 byte rcomp, default to 0x97 0x00. 51 + All other devices have one byte rcomp, default to 0x97. 52 + 53 + interrupts: 54 + maxItems: 1 55 + 56 + wakeup-source: 57 + type: boolean 58 + description: | 59 + Use this property to use alert low SoC level interrupt as wake up source. 60 + 61 + required: 62 + - compatible 63 + - reg 64 + 65 + additionalProperties: false 66 + 67 + examples: 68 + - | 69 + i2c0 { 70 + #address-cells = <1>; 71 + #size-cells = <0>; 72 + 73 + battery@36 { 74 + compatible = "maxim,max17048"; 75 + reg = <0x36>; 76 + maxim,rcomp = /bits/ 8 <0x56>; 77 + maxim,alert-low-soc-level = <10>; 78 + maxim,double-soc; 79 + }; 80 + }; 81 + - | 82 + #include <dt-bindings/interrupt-controller/irq.h> 83 + i2c0 { 84 + #address-cells = <1>; 85 + #size-cells = <0>; 86 + 87 + battery@36 { 88 + compatible = "maxim,max77836-battery"; 89 + reg = <0x36>; 90 + maxim,alert-low-soc-level = <10>; 91 + interrupt-parent = <&gpio7>; 92 + interrupts = <2 IRQ_TYPE_EDGE_FALLING>; 93 + wakeup-source; 94 + }; 95 + };
+78
Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/maxim,max17042.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Maxim 17042 fuel gauge series 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + enum: 18 + - maxim,max17042 19 + - maxim,max17047 20 + - maxim,max17050 21 + - maxim,max17055 22 + 23 + reg: 24 + maxItems: 1 25 + 26 + interrupts: 27 + maxItems: 1 28 + 29 + maxim,rsns-microohm: 30 + $ref: /schemas/types.yaml#/definitions/uint32 31 + description: | 32 + Resistance of rsns resistor in micro Ohms (datasheet-recommended value is 10000). 33 + Defining this property enables current-sense functionality. 34 + 35 + maxim,cold-temp: 36 + $ref: /schemas/types.yaml#/definitions/uint32 37 + description: | 38 + Temperature threshold to report battery as cold (in tenths of degree Celsius). 39 + Default is not to report cold events. 40 + 41 + maxim,over-heat-temp: 42 + $ref: /schemas/types.yaml#/definitions/uint32 43 + description: | 44 + Temperature threshold to report battery as over heated (in tenths of degree Celsius). 45 + Default is not to report over heating events. 46 + 47 + maxim,dead-volt: 48 + $ref: /schemas/types.yaml#/definitions/uint32 49 + description: | 50 + Voltage threshold to report battery as dead (in mV). 51 + Default is not to report dead battery events. 52 + 53 + maxim,over-volt: 54 + $ref: /schemas/types.yaml#/definitions/uint32 55 + description: | 56 + Voltage threshold to report battery as over voltage (in mV). 57 + Default is not to report over-voltage events. 58 + 59 + required: 60 + - compatible 61 + - reg 62 + 63 + additionalProperties: false 64 + 65 + examples: 66 + - | 67 + i2c0 { 68 + #address-cells = <1>; 69 + #size-cells = <0>; 70 + 71 + battery@36 { 72 + compatible = "maxim,max17042"; 73 + reg = <0x36>; 74 + maxim,rsns-microohm = <10000>; 75 + maxim,over-heat-temp = <600>; 76 + maxim,over-volt = <4300>; 77 + }; 78 + };
+67
Documentation/devicetree/bindings/power/supply/maxim,max8903.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/maxim,max8903.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Maxim Semiconductor MAX8903 Battery Charger 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: maxim,max8903 18 + 19 + dok-gpios: 20 + maxItems: 1 21 + description: Valid DC power has been detected (active low, input) 22 + 23 + uok-gpios: 24 + maxItems: 1 25 + description: Valid USB power has been detected (active low, input) 26 + 27 + cen-gpios: 28 + maxItems: 1 29 + description: Charge enable pin (active low, output) 30 + 31 + chg-gpios: 32 + maxItems: 1 33 + description: Charger status pin (active low, input) 34 + 35 + flt-gpios: 36 + maxItems: 1 37 + description: Fault pin (active low, output) 38 + 39 + dcm-gpios: 40 + maxItems: 1 41 + description: Current limit mode setting (DC=1 or USB=0, output) 42 + 43 + usus-gpios: 44 + maxItems: 1 45 + description: USB suspend pin (active high, output) 46 + 47 + required: 48 + - compatible 49 + 50 + anyOf: 51 + - required: 52 + - dok-gpios 53 + - required: 54 + - uok-gpios 55 + 56 + additionalProperties: false 57 + 58 + examples: 59 + - | 60 + #include <dt-bindings/gpio/gpio.h> 61 + charger { 62 + compatible = "maxim,max8903"; 63 + dok-gpios = <&gpio2 3 GPIO_ACTIVE_LOW>; 64 + flt-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>; 65 + chg-gpios = <&gpio3 15 GPIO_ACTIVE_LOW>; 66 + cen-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>; 67 + };
-27
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt
··· 1 - Microchip UCS1002 USB Port Power Controller 2 - 3 - Required properties: 4 - - compatible : Should be "microchip,ucs1002"; 5 - - reg : I2C slave address 6 - 7 - Optional properties: 8 - - interrupts : A list of interrupts lines present (could be either 9 - corresponding to A_DET# pin, ALERT# pin, or both) 10 - - interrupt-names : A list of interrupt names. Should contain (if 11 - present): 12 - - "a_det" for line connected to A_DET# pin 13 - - "alert" for line connected to ALERT# pin 14 - Both are expected to be IRQ_TYPE_EDGE_BOTH 15 - Example: 16 - 17 - &i2c3 { 18 - charger@32 { 19 - compatible = "microchip,ucs1002"; 20 - pinctrl-names = "default"; 21 - pinctrl-0 = <&pinctrl_ucs1002_pins>; 22 - reg = <0x32>; 23 - interrupts-extended = <&gpio5 2 IRQ_TYPE_EDGE_BOTH>, 24 - <&gpio3 21 IRQ_TYPE_EDGE_BOTH>; 25 - interrupt-names = "a_det", "alert"; 26 - }; 27 - };
+51
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/power/supply/microchip,ucs1002.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Microchip UCS1002 USB Port Power Controller 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + properties: 13 + compatible: 14 + const: microchip,ucs1002 15 + 16 + reg: 17 + maxItems: 1 18 + 19 + interrupts: 20 + maxItems: 2 21 + 22 + interrupt-names: 23 + oneOf: 24 + - items: 25 + - const: a_det 26 + - const: alert 27 + - const: a_det 28 + - const: alert 29 + 30 + required: 31 + - compatible 32 + - reg 33 + 34 + additionalProperties: false 35 + 36 + examples: 37 + - | 38 + #include <dt-bindings/interrupt-controller/irq.h> 39 + 40 + i2c { 41 + #address-cells = <1>; 42 + #size-cells = <0>; 43 + 44 + charger@32 { 45 + compatible = "microchip,ucs1002"; 46 + reg = <0x32>; 47 + interrupts-extended = <&gpio5 2 IRQ_TYPE_EDGE_BOTH>, 48 + <&gpio3 21 IRQ_TYPE_EDGE_BOTH>; 49 + interrupt-names = "a_det", "alert"; 50 + }; 51 + };
+49
Documentation/devicetree/bindings/power/supply/nokia,n900-battery.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/nokia,n900-battery.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Nokia N900 battery 8 + 9 + maintainers: 10 + - Pali Rohár <pali@kernel.org> 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + const: nokia,n900-battery 19 + 20 + io-channels: 21 + items: 22 + - description: ADC channel for temperature reading 23 + - description: ADC channel for battery size identification 24 + - description: ADC channel to measure the battery voltage 25 + 26 + io-channel-names: 27 + items: 28 + - const: temp 29 + - const: bsi 30 + - const: vbat 31 + 32 + required: 33 + - compatible 34 + - io-channels 35 + - io-channel-names 36 + 37 + additionalProperties: false 38 + 39 + examples: 40 + - | 41 + battery { 42 + compatible = "nokia,n900-battery"; 43 + io-channels = <&twl4030_madc 0>, 44 + <&twl4030_madc 4>, 45 + <&twl4030_madc 12>; 46 + io-channel-names = "temp", 47 + "bsi", 48 + "vbat"; 49 + };
+27
Documentation/devicetree/bindings/power/supply/olpc-battery.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/olpc-battery.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: OLPC Battery 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + oneOf: 18 + - items: 19 + - const: olpc,xo1.5-battery 20 + - const: olpc,xo1-battery 21 + - items: 22 + - const: olpc,xo1-battery 23 + 24 + required: 25 + - compatible 26 + 27 + additionalProperties: false
-5
Documentation/devicetree/bindings/power/supply/olpc_battery.txt
··· 1 - OLPC battery 2 - ~~~~~~~~~~~~ 3 - 4 - Required properties: 5 - - compatible : "olpc,xo1-battery" or "olpc,xo1.5-battery"
-2
Documentation/devicetree/bindings/power/supply/power_supply.txt
··· 1 - This binding has been converted to yaml please see power-supply.yaml in this 2 - directory.
-48
Documentation/devicetree/bindings/power/supply/qcom,coincell-charger.txt
··· 1 - Qualcomm Coincell Charger: 2 - 3 - The hardware block controls charging for a coincell or capacitor that is 4 - used to provide power backup for certain features of the power management 5 - IC (PMIC) 6 - 7 - - compatible: 8 - Usage: required 9 - Value type: <string> 10 - Definition: must be: "qcom,pm8941-coincell" 11 - 12 - - reg: 13 - Usage: required 14 - Value type: <u32> 15 - Definition: base address of the coincell charger registers 16 - 17 - - qcom,rset-ohms: 18 - Usage: required 19 - Value type: <u32> 20 - Definition: resistance (in ohms) for current-limiting resistor 21 - must be one of: 800, 1200, 1700, 2100 22 - 23 - - qcom,vset-millivolts: 24 - Usage: required 25 - Value type: <u32> 26 - Definition: voltage (in millivolts) to apply for charging 27 - must be one of: 2500, 3000, 3100, 3200 28 - 29 - - qcom,charger-disable: 30 - Usage: optional 31 - Value type: <boolean> 32 - Definition: defining this property disables charging 33 - 34 - This charger is a sub-node of one of the 8941 PMIC blocks, and is specified 35 - as a child node in DTS of that node. See ../mfd/qcom,spmi-pmic.txt and 36 - ../mfd/qcom-pm8xxx.txt 37 - 38 - Example: 39 - 40 - pm8941@0 { 41 - coincell@2800 { 42 - compatible = "qcom,pm8941-coincell"; 43 - reg = <0x2800>; 44 - 45 - qcom,rset-ohms = <2100>; 46 - qcom,vset-millivolts = <3000>; 47 - }; 48 - };
+169
Documentation/devicetree/bindings/power/supply/qcom,pm8941-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/power/supply/qcom,pm8941-charger.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm Switch-Mode Battery Charger and Boost 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + properties: 13 + compatible: 14 + const: qcom,pm8941-charger 15 + 16 + reg: 17 + maxItems: 1 18 + 19 + interrupts: 20 + items: 21 + - description: charge done 22 + - description: charge fast mode 23 + - description: charge trickle mode 24 + - description: battery temperature ok 25 + - description: battery present 26 + - description: charger disconnected 27 + - description: USB-in valid 28 + - description: DC-in valid 29 + 30 + interrupt-names: 31 + items: 32 + - const: chg-done 33 + - const: chg-fast 34 + - const: chg-trkl 35 + - const: bat-temp-ok 36 + - const: bat-present 37 + - const: chg-gone 38 + - const: usb-valid 39 + - const: dc-valid 40 + 41 + qcom,fast-charge-current-limit: 42 + $ref: /schemas/types.yaml#/definitions/uint32 43 + minimum: 100000 44 + maximum: 3000000 45 + description: Maximum charge current in uA; May be clamped to safety limits; Defaults to 1A 46 + 47 + qcom,fast-charge-low-threshold-voltage: 48 + $ref: /schemas/types.yaml#/definitions/uint32 49 + minimum: 2100000 50 + maximum: 3600000 51 + description: | 52 + Battery voltage limit in uV above which fast charging may operate; Defaults to 3.2V 53 + Below this value linear or switch-mode auto-trickle-charging will operate. 54 + 55 + qcom,fast-charge-high-threshold-voltage: 56 + $ref: /schemas/types.yaml#/definitions/uint32 57 + minimum: 3240000 58 + maximum: 5000000 59 + description: | 60 + Battery voltage limit in uV below which fast charging may operate; Defaults to 4.2V 61 + The fast charger will attempt to charge the battery to this voltage. 62 + May be clamped to safety limits. 63 + 64 + qcom,fast-charge-safe-voltage: 65 + $ref: /schemas/types.yaml#/definitions/uint32 66 + minimum: 3240000 67 + maximum: 5000000 68 + description: | 69 + Maximum safe battery voltage in uV; May be pre-set by bootloader, in which case, 70 + setting this will harmlessly fail. The property 'fast-charge-high-watermark' will 71 + be clamped by this value. Defaults to 4.2V. 72 + 73 + qcom,fast-charge-safe-current: 74 + $ref: /schemas/types.yaml#/definitions/uint32 75 + minimum: 100000 76 + maximum: 3000000 77 + description: | 78 + Maximum safe battery charge current in uA; May pre-set by bootloader, in which case, 79 + setting this will harmlessly fail. The property 'qcom,fast-charge-current-limit' 80 + will be clamped by this value. Defaults to 1A. 81 + 82 + qcom,auto-recharge-threshold-voltage: 83 + $ref: /schemas/types.yaml#/definitions/uint32 84 + minimum: 3240000 85 + maximum: 5000000 86 + description: | 87 + Battery voltage limit in uV below which auto-recharge functionality will restart charging 88 + after end-of-charge; The high cutoff limit for auto-recharge is 5% above this value. 89 + Defaults to 4.1V. 90 + 91 + qcom,minimum-input-voltage: 92 + $ref: /schemas/types.yaml#/definitions/uint32 93 + minimum: 4200000 94 + maximum: 9600000 95 + description: | 96 + Input voltage level in uV above which charging may operate. Defaults to 4.3V. 97 + 98 + qcom,dc-current-limit: 99 + $ref: /schemas/types.yaml#/definitions/uint32 100 + minimum: 100000 101 + maximum: 2500000 102 + description: | 103 + Default DC charge current limit in uA. Defaults to 100mA. 104 + 105 + qcom,disable-dc: 106 + type: boolean 107 + description: Disable DC charger 108 + 109 + qcom,jeita-extended-temp-range: 110 + type: boolean 111 + description: | 112 + Enable JEITA extended temperature range; This does *not* adjust the maximum charge 113 + voltage or current in the extended temperature range. It only allows charging when 114 + the battery is in the extended temperature range. Voltage/current regulation must 115 + be done externally to fully comply with the JEITA safety guidelines if this flag 116 + is set. 117 + 118 + usb-otg-in-supply: 119 + description: Reference to the regulator supplying power to the USB_OTG_IN pin. 120 + 121 + otg-vbus: 122 + type: object 123 + description: | 124 + This node defines a regulator used to control the direction of VBUS voltage. 125 + Specifically whether to supply voltage to VBUS for host mode operation of the OTG port, 126 + or allow input voltage from external VBUS for charging. In the hardware, the supply for 127 + this regulator comes from usb_otg_in-supply. 128 + 129 + required: 130 + - compatible 131 + - reg 132 + - interrupts 133 + - interrupt-names 134 + 135 + additionalProperties: false 136 + 137 + examples: 138 + - | 139 + #include <dt-bindings/interrupt-controller/irq.h> 140 + pmic { 141 + #address-cells = <1>; 142 + #size-cells = <0>; 143 + 144 + charger@1000 { 145 + compatible = "qcom,pm8941-charger"; 146 + reg = <0x1000>; 147 + interrupts = <0x0 0x10 7 IRQ_TYPE_EDGE_BOTH>, 148 + <0x0 0x10 5 IRQ_TYPE_EDGE_BOTH>, 149 + <0x0 0x10 4 IRQ_TYPE_EDGE_BOTH>, 150 + <0x0 0x12 1 IRQ_TYPE_EDGE_BOTH>, 151 + <0x0 0x12 0 IRQ_TYPE_EDGE_BOTH>, 152 + <0x0 0x13 2 IRQ_TYPE_EDGE_BOTH>, 153 + <0x0 0x13 1 IRQ_TYPE_EDGE_BOTH>, 154 + <0x0 0x14 1 IRQ_TYPE_EDGE_BOTH>; 155 + interrupt-names = "chg-done", 156 + "chg-fast", 157 + "chg-trkl", 158 + "bat-temp-ok", 159 + "bat-present", 160 + "chg-gone", 161 + "usb-valid", 162 + "dc-valid"; 163 + qcom,fast-charge-current-limit = <1000000>; 164 + qcom,dc-current-limit = <1000000>; 165 + usb-otg-in-supply = <&pm8941_5vs1>; 166 + 167 + otg-vbus {}; 168 + }; 169 + };
+57
Documentation/devicetree/bindings/power/supply/qcom,pm8941-coincell.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/power/supply/qcom,pm8941-coincell.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm Coincell Charger 8 + 9 + description: | 10 + The hardware block controls charging for a coincell or capacitor that is 11 + used to provide power backup for certain features of the power management 12 + IC (PMIC) 13 + 14 + maintainers: 15 + - Sebastian Reichel <sre@kernel.org> 16 + 17 + properties: 18 + compatible: 19 + const: qcom,pm8941-coincell 20 + 21 + reg: 22 + maxItems: 1 23 + 24 + qcom,rset-ohms: 25 + description: resistance (in ohms) for current-limiting resistor 26 + enum: [ 800, 1200, 1700, 2100 ] 27 + 28 + qcom,vset-millivolts: 29 + $ref: /schemas/types.yaml#/definitions/uint32 30 + description: voltage (in millivolts) to apply for charging 31 + enum: [ 2500, 3000, 3100, 3200 ] 32 + 33 + qcom,charger-disable: 34 + type: boolean 35 + description: defining this property disables charging 36 + 37 + required: 38 + - compatible 39 + - reg 40 + - qcom,rset-ohms 41 + - qcom,vset-millivolts 42 + 43 + additionalProperties: false 44 + 45 + examples: 46 + - | 47 + pmic { 48 + #address-cells = <1>; 49 + #size-cells = <0>; 50 + 51 + charger@2800 { 52 + compatible = "qcom,pm8941-coincell"; 53 + reg = <0x2800>; 54 + qcom,rset-ohms = <2100>; 55 + qcom,vset-millivolts = <3000>; 56 + }; 57 + };
-150
Documentation/devicetree/bindings/power/supply/qcom_smbb.txt
··· 1 - Qualcomm Switch-Mode Battery Charger and Boost 2 - 3 - PROPERTIES 4 - - compatible: 5 - Usage: required 6 - Value type: <stringlist> 7 - Description: Must be one of: 8 - - "qcom,pm8941-charger" 9 - 10 - - reg: 11 - Usage: required 12 - Value type: <prop-encoded-array> 13 - Description: Base address of registers for SMBB block 14 - 15 - - interrupts: 16 - Usage: required 17 - Value type: <prop-encoded-array> 18 - Description: The format of the specifier is defined by the binding document 19 - describing the node's interrupt parent. Must contain one 20 - specifier for each of the following interrupts, in order: 21 - - charge done 22 - - charge fast mode 23 - - charge trickle mode 24 - - battery temperature ok 25 - - battery present 26 - - charger disconnected 27 - - USB-in valid 28 - - DC-in valid 29 - 30 - - interrupt-names: 31 - Usage: required 32 - Value type: <stringlist> 33 - Description: Must contain the following list, strictly ordered: 34 - "chg-done", 35 - "chg-fast", 36 - "chg-trkl", 37 - "bat-temp-ok", 38 - "bat-present", 39 - "chg-gone", 40 - "usb-valid", 41 - "dc-valid" 42 - 43 - - qcom,fast-charge-current-limit: 44 - Usage: optional (default: 1A, or pre-configured value) 45 - Value type: <u32>; uA; range [100mA : 3A] 46 - Description: Maximum charge current; May be clamped to safety limits. 47 - 48 - - qcom,fast-charge-low-threshold-voltage: 49 - Usage: optional (default: 3.2V, or pre-configured value) 50 - Value type: <u32>; uV; range [2.1V : 3.6V] 51 - Description: Battery voltage limit above which fast charging may operate; 52 - Below this value linear or switch-mode auto-trickle-charging 53 - will operate. 54 - 55 - - qcom,fast-charge-high-threshold-voltage: 56 - Usage: optional (default: 4.2V, or pre-configured value) 57 - Value type: <u32>; uV; range [3.24V : 5V] 58 - Description: Battery voltage limit below which fast charging may operate; 59 - The fast charger will attempt to charge the battery to this 60 - voltage. May be clamped to safety limits. 61 - 62 - - qcom,fast-charge-safe-voltage: 63 - Usage: optional (default: 4.2V, or pre-configured value) 64 - Value type: <u32>; uV; range [3.24V : 5V] 65 - Description: Maximum safe battery voltage; May be pre-set by bootloader, in 66 - which case, setting this will harmlessly fail. The property 67 - 'fast-charge-high-watermark' will be clamped by this value. 68 - 69 - - qcom,fast-charge-safe-current: 70 - Usage: optional (default: 1A, or pre-configured value) 71 - Value type: <u32>; uA; range [100mA : 3A] 72 - Description: Maximum safe battery charge current; May pre-set by bootloader, 73 - in which case, setting this will harmlessly fail. The property 74 - 'qcom,fast-charge-current-limit' will be clamped by this value. 75 - 76 - - qcom,auto-recharge-threshold-voltage: 77 - Usage: optional (default: 4.1V, or pre-configured value) 78 - Value type: <u32>; uV; range [3.24V : 5V] 79 - Description: Battery voltage limit below which auto-recharge functionality 80 - will restart charging after end-of-charge; The high cutoff 81 - limit for auto-recharge is 5% above this value. 82 - 83 - - qcom,minimum-input-voltage: 84 - Usage: optional (default: 4.3V, or pre-configured value) 85 - Value type: <u32>; uV; range [4.2V : 9.6V] 86 - Description: Input voltage level above which charging may operate 87 - 88 - - qcom,dc-current-limit: 89 - Usage: optional (default: 100mA, or pre-configured value) 90 - Value type: <u32>; uA; range [100mA : 2.5A] 91 - Description: Default DC charge current limit 92 - 93 - - qcom,disable-dc: 94 - Usage: optional (default: false) 95 - Value type: boolean: <u32> or <empty> 96 - Description: Disable DC charger 97 - 98 - - qcom,jeita-extended-temp-range: 99 - Usage: optional (default: false) 100 - Value type: boolean: <u32> or <empty> 101 - Description: Enable JEITA extended temperature range; This does *not* 102 - adjust the maximum charge voltage or current in the extended 103 - temperature range. It only allows charging when the battery 104 - is in the extended temperature range. Voltage/current 105 - regulation must be done externally to fully comply with 106 - the JEITA safety guidelines if this flag is set. 107 - 108 - - usb_otg_in-supply: 109 - Usage: optional 110 - Value type: <phandle> 111 - Description: Reference to the regulator supplying power to the USB_OTG_IN 112 - pin. 113 - 114 - child nodes: 115 - - otg-vbus: 116 - Usage: optional 117 - Description: This node defines a regulator used to control the direction 118 - of VBUS voltage - specifically: whether to supply voltage 119 - to VBUS for host mode operation of the OTG port, or allow 120 - input voltage from external VBUS for charging. In the 121 - hardware, the supply for this regulator comes from 122 - usb_otg_in-supply. 123 - 124 - EXAMPLE 125 - charger@1000 { 126 - compatible = "qcom,pm8941-charger"; 127 - reg = <0x1000 0x700>; 128 - interrupts = <0x0 0x10 7 IRQ_TYPE_EDGE_BOTH>, 129 - <0x0 0x10 5 IRQ_TYPE_EDGE_BOTH>, 130 - <0x0 0x10 4 IRQ_TYPE_EDGE_BOTH>, 131 - <0x0 0x12 1 IRQ_TYPE_EDGE_BOTH>, 132 - <0x0 0x12 0 IRQ_TYPE_EDGE_BOTH>, 133 - <0x0 0x13 2 IRQ_TYPE_EDGE_BOTH>, 134 - <0x0 0x13 1 IRQ_TYPE_EDGE_BOTH>, 135 - <0x0 0x14 1 IRQ_TYPE_EDGE_BOTH>; 136 - interrupt-names = "chg-done", 137 - "chg-fast", 138 - "chg-trkl", 139 - "bat-temp-ok", 140 - "bat-present", 141 - "chg-gone", 142 - "usb-valid", 143 - "dc-valid"; 144 - 145 - qcom,fast-charge-current-limit = <1000000>; 146 - qcom,dc-charge-current-limit = <1000000>; 147 - usb_otg_in-supply = <&pm8941_5vs1>; 148 - 149 - otg-vbus {}; 150 - };
+90
Documentation/devicetree/bindings/power/supply/richtek,rt9455.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/richtek,rt9455.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Binding for Richtek rt9455 battery charger 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: richtek,rt9455 18 + 19 + reg: 20 + maxItems: 1 21 + 22 + interrupts: 23 + maxItems: 1 24 + 25 + richtek,output-charge-current: 26 + $ref: /schemas/types.yaml#/definitions/uint32 27 + description: output current from the charger to the battery, in uA. 28 + 29 + richtek,end-of-charge-percentage: 30 + $ref: /schemas/types.yaml#/definitions/uint32 31 + description: | 32 + percent of the output charge current. When the current in constant-voltage phase drops 33 + below output_charge_current x end-of-charge-percentage, charge is terminated. 34 + 35 + richtek,battery-regulation-voltage: 36 + $ref: /schemas/types.yaml#/definitions/uint32 37 + description: maximum battery voltage in uV. 38 + 39 + richtek,boost-output-voltage: 40 + $ref: /schemas/types.yaml#/definitions/uint32 41 + description: | 42 + maximum voltage provided to consumer devices, when the charger is in boost mode, in uV. 43 + 44 + richtek,min-input-voltage-regulation: 45 + $ref: /schemas/types.yaml#/definitions/uint32 46 + description: | 47 + input voltage level in uV, used to decrease voltage level when the over current of the 48 + input power source occurs. This prevents input voltage drop due to insufficient 49 + current provided by the power source. Defaults to 4500000 uV (4.5V). 50 + 51 + richtek,avg-input-current-regulation: 52 + $ref: /schemas/types.yaml#/definitions/uint32 53 + description: | 54 + input current value in uA drained by the charger from the power source. 55 + Defaults to 500000 uA (500mA). 56 + 57 + required: 58 + - compatible 59 + - reg 60 + - interrupts 61 + - richtek,output-charge-current 62 + - richtek,end-of-charge-percentage 63 + - richtek,battery-regulation-voltage 64 + - richtek,boost-output-voltage 65 + 66 + additionalProperties: false 67 + 68 + examples: 69 + - | 70 + #include <dt-bindings/interrupt-controller/irq.h> 71 + i2c0 { 72 + #address-cells = <1>; 73 + #size-cells = <0>; 74 + 75 + charger@22 { 76 + compatible = "richtek,rt9455"; 77 + reg = <0x22>; 78 + 79 + interrupt-parent = <&gpio1>; 80 + interrupts = <0 IRQ_TYPE_LEVEL_LOW>; 81 + 82 + richtek,output-charge-current = <500000>; 83 + richtek,end-of-charge-percentage = <10>; 84 + richtek,battery-regulation-voltage = <4200000>; 85 + richtek,boost-output-voltage = <5050000>; 86 + 87 + richtek,min-input-voltage-regulation = <4500000>; 88 + richtek,avg-input-current-regulation = <500000>; 89 + }; 90 + };
+1 -1
Documentation/devicetree/bindings/power/supply/rohm,bd99954.yaml
··· 110 110 # multipleOf: 64000 111 111 # a charge cycle terminates when the battery voltage is above recharge 112 112 # threshold, and the current is below this setting (7 in above chart) 113 - # See also Documentation/devicetree/bindings/power/supply/battery.txt 113 + # See also Documentation/devicetree/bindings/power/supply/battery.yaml 114 114 115 115 reg: 116 116 maxItems: 1
-46
Documentation/devicetree/bindings/power/supply/rt9455_charger.txt
··· 1 - Binding for Richtek rt9455 battery charger 2 - 3 - Required properties: 4 - - compatible: it should contain one of the following: 5 - "richtek,rt9455". 6 - - reg: integer, i2c address of the device. 7 - - interrupts: interrupt mapping for GPIO IRQ, it should be 8 - configured with IRQ_TYPE_LEVEL_LOW flag. 9 - - richtek,output-charge-current: integer, output current from the charger to the 10 - battery, in uA. 11 - - richtek,end-of-charge-percentage: integer, percent of the output charge current. 12 - When the current in constant-voltage phase drops 13 - below output_charge_current x end-of-charge-percentage, 14 - charge is terminated. 15 - - richtek,battery-regulation-voltage: integer, maximum battery voltage in uV. 16 - - richtek,boost-output-voltage: integer, maximum voltage provided to consumer 17 - devices, when the charger is in boost mode, in uV. 18 - 19 - Optional properties: 20 - - richtek,min-input-voltage-regulation: integer, input voltage level in uV, used to 21 - decrease voltage level when the over current 22 - of the input power source occurs. 23 - This prevents input voltage drop due to insufficient 24 - current provided by the power source. 25 - Default: 4500000 uV (4.5V) 26 - - richtek,avg-input-current-regulation: integer, input current value in uA drained by the 27 - charger from the power source. 28 - Default: 500000 uA (500mA) 29 - 30 - Example: 31 - 32 - rt9455@22 { 33 - compatible = "richtek,rt9455"; 34 - reg = <0x22>; 35 - 36 - interrupt-parent = <&gpio1>; 37 - interrupts = <0 IRQ_TYPE_LEVEL_LOW>; 38 - 39 - richtek,output-charge-current = <500000>; 40 - richtek,end-of-charge-percentage = <10>; 41 - richtek,battery-regulation-voltage = <4200000>; 42 - richtek,boost-output-voltage = <5050000>; 43 - 44 - richtek,min-input-voltage-regulation = <4500000>; 45 - richtek,avg-input-current-regulation = <500000>; 46 - };
-25
Documentation/devicetree/bindings/power/supply/rx51-battery.txt
··· 1 - Binding for Nokia N900 battery 2 - 3 - The Nokia N900 battery status can be read via the TWL4030's A/D converter. 4 - 5 - Required properties: 6 - - compatible: Should contain one of the following: 7 - * "nokia,n900-battery" 8 - - io-channels: Should contain IIO channel specifiers 9 - for each element in io-channel-names. 10 - - io-channel-names: Should contain the following values: 11 - * "temp" - The ADC channel for temperature reading 12 - * "bsi" - The ADC channel for battery size identification 13 - * "vbat" - The ADC channel to measure the battery voltage 14 - 15 - Example from Nokia N900: 16 - 17 - battery: n900-battery { 18 - compatible = "nokia,n900-battery"; 19 - io-channels = <&twl4030_madc 0>, 20 - <&twl4030_madc 4>, 21 - <&twl4030_madc 12>; 22 - io-channel-names = "temp", 23 - "bsi", 24 - "vbat"; 25 - };
+5 -2
Documentation/devicetree/bindings/power/supply/sbs,sbs-battery.yaml
··· 12 12 description: | 13 13 Battery compatible with the smart battery system specifications 14 14 15 - properties: 15 + allOf: 16 + - $ref: power-supply.yaml# 16 17 18 + properties: 17 19 compatible: 18 20 oneOf: 19 21 - items: 20 22 - enum: 23 + - ti,bq20z45 21 24 - ti,bq20z65 22 25 - ti,bq20z75 23 26 - enum: ··· 63 60 - compatible 64 61 - reg 65 62 66 - additionalProperties: false 63 + unevaluatedProperties: false 67 64 68 65 examples: 69 66 - |
+55
Documentation/devicetree/bindings/power/supply/sbs,sbs-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/power/supply/sbs,sbs-charger.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: SBS compliant charger 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + description: | 13 + Charger compatible with the smart battery system specifications 14 + 15 + allOf: 16 + - $ref: power-supply.yaml# 17 + 18 + properties: 19 + compatible: 20 + oneOf: 21 + - items: 22 + - enum: 23 + - lltc,ltc4100 24 + - enum: 25 + - sbs,sbs-charger 26 + - items: 27 + - const: sbs,sbs-charger 28 + 29 + reg: 30 + maxItems: 1 31 + 32 + interrupts: 33 + maxItems: 1 34 + 35 + required: 36 + - compatible 37 + - reg 38 + 39 + additionalProperties: false 40 + 41 + examples: 42 + - | 43 + #include <dt-bindings/interrupt-controller/irq.h> 44 + 45 + i2c { 46 + #address-cells = <1>; 47 + #size-cells = <0>; 48 + 49 + charger@9 { 50 + compatible = "lltc,ltc4100", "sbs,sbs-charger"; 51 + reg = <0x9>; 52 + interrupt-parent = <&gpio6>; 53 + interrupts = <7 IRQ_TYPE_LEVEL_LOW>; 54 + }; 55 + };
-66
Documentation/devicetree/bindings/power/supply/sbs,sbs-manager.txt
··· 1 - Binding for sbs-manager 2 - 3 - Required properties: 4 - - compatible: "<vendor>,<part-number>", "sbs,sbs-charger" as fallback. The part 5 - number compatible string might be used in order to take care of vendor 6 - specific registers. 7 - - reg: integer, i2c address of the device. Should be <0xa>. 8 - Optional properties: 9 - - gpio-controller: Marks the port as GPIO controller. 10 - See "gpio-specifier" in .../devicetree/bindings/gpio/gpio.txt. 11 - - #gpio-cells: Should be <2>. The first cell is the pin number, the second cell 12 - is used to specify optional parameters: 13 - See "gpio-specifier" in .../devicetree/bindings/gpio/gpio.txt. 14 - 15 - From OS view the device is basically an i2c-mux used to communicate with up to 16 - four smart battery devices at address 0xb. The driver actually implements this 17 - behaviour. So standard i2c-mux nodes can be used to register up to four slave 18 - batteries. Channels will be numerated starting from 1 to 4. 19 - 20 - Example: 21 - 22 - batman@a { 23 - compatible = "lltc,ltc1760", "sbs,sbs-manager"; 24 - reg = <0x0a>; 25 - #address-cells = <1>; 26 - #size-cells = <0>; 27 - 28 - gpio-controller; 29 - #gpio-cells = <2>; 30 - 31 - i2c@1 { 32 - #address-cells = <1>; 33 - #size-cells = <0>; 34 - reg = <1>; 35 - 36 - battery@b { 37 - compatible = "ti,bq2060", "sbs,sbs-battery"; 38 - reg = <0x0b>; 39 - sbs,battery-detect-gpios = <&batman 1 1>; 40 - }; 41 - }; 42 - 43 - i2c@2 { 44 - #address-cells = <1>; 45 - #size-cells = <0>; 46 - reg = <2>; 47 - 48 - battery@b { 49 - compatible = "ti,bq2060", "sbs,sbs-battery"; 50 - reg = <0x0b>; 51 - sbs,battery-detect-gpios = <&batman 2 1>; 52 - }; 53 - }; 54 - 55 - i2c@3 { 56 - #address-cells = <1>; 57 - #size-cells = <0>; 58 - reg = <3>; 59 - 60 - battery@b { 61 - compatible = "ti,bq2060", "sbs,sbs-battery"; 62 - reg = <0x0b>; 63 - sbs,battery-detect-gpios = <&batman 3 1>; 64 - }; 65 - }; 66 - };
+107
Documentation/devicetree/bindings/power/supply/sbs,sbs-manager.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/power/supply/sbs,sbs-manager.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: SBS compliant manger 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + oneOf: 18 + - items: 19 + - enum: 20 + - lltc,ltc1760 21 + - enum: 22 + - sbs,sbs-manager 23 + - items: 24 + - const: sbs,sbs-manager 25 + 26 + reg: 27 + const: 0xa 28 + 29 + "#address-cells": 30 + const: 1 31 + 32 + "#size-cells": 33 + const: 0 34 + 35 + gpio-controller: true 36 + 37 + "#gpio-cells": 38 + const: 2 39 + 40 + required: 41 + - compatible 42 + - reg 43 + 44 + additionalProperties: false 45 + 46 + patternProperties: 47 + "^i2c@[1-4]$": 48 + type: object 49 + 50 + allOf: 51 + - $ref: /schemas/i2c/i2c-controller.yaml# 52 + 53 + examples: 54 + - | 55 + #include <dt-bindings/interrupt-controller/irq.h> 56 + #include <dt-bindings/gpio/gpio.h> 57 + 58 + i2c { 59 + #address-cells = <1>; 60 + #size-cells = <0>; 61 + 62 + batman: battery-manager@a { 63 + compatible = "lltc,ltc1760", "sbs,sbs-manager"; 64 + reg = <0x0a>; 65 + #address-cells = <1>; 66 + #size-cells = <0>; 67 + 68 + gpio-controller; 69 + #gpio-cells = <2>; 70 + 71 + i2c@1 { 72 + #address-cells = <1>; 73 + #size-cells = <0>; 74 + reg = <1>; 75 + 76 + battery@b { 77 + compatible = "ti,bq20z65", "sbs,sbs-battery"; 78 + reg = <0x0b>; 79 + sbs,battery-detect-gpios = <&batman 1 1>; 80 + }; 81 + }; 82 + 83 + i2c@2 { 84 + #address-cells = <1>; 85 + #size-cells = <0>; 86 + reg = <2>; 87 + 88 + battery@b { 89 + compatible = "ti,bq20z65", "sbs,sbs-battery"; 90 + reg = <0x0b>; 91 + sbs,battery-detect-gpios = <&batman 2 1>; 92 + }; 93 + }; 94 + 95 + i2c@3 { 96 + #address-cells = <1>; 97 + #size-cells = <0>; 98 + reg = <3>; 99 + 100 + battery@b { 101 + compatible = "ti,bq20z65", "sbs,sbs-battery"; 102 + reg = <0x0b>; 103 + sbs,battery-detect-gpios = <&batman 3 1>; 104 + }; 105 + }; 106 + }; 107 + };
-21
Documentation/devicetree/bindings/power/supply/sbs_sbs-charger.txt
··· 1 - SBS sbs-charger 2 - ~~~~~~~~~~ 3 - 4 - Required properties: 5 - - compatible: "<vendor>,<part-number>", "sbs,sbs-charger" as fallback. The part 6 - number compatible string might be used in order to take care of vendor 7 - specific registers. 8 - 9 - Optional properties: 10 - - interrupts: Interrupt mapping for GPIO IRQ. Use in conjunction with 11 - "interrupt-parent". If an interrupt is not provided the driver will switch 12 - automatically to polling. 13 - 14 - Example: 15 - 16 - ltc4100@9 { 17 - compatible = "lltc,ltc4100", "sbs,sbs-charger"; 18 - reg = <0x9>; 19 - interrupt-parent = <&gpio6>; 20 - interrupts = <7 IRQ_TYPE_LEVEL_LOW>; 21 - };
+53
Documentation/devicetree/bindings/power/supply/sc2731-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/sc2731-charger.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Spreadtrum SC2731 PMICs battery charger binding 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: sprd,sc2731-charger 18 + 19 + reg: 20 + maxItems: 1 21 + 22 + phys: 23 + $ref: /schemas/types.yaml#/definitions/phandle 24 + description: phandle to the USB phy 25 + 26 + monitored-battery: 27 + description: | 28 + The charger uses the following battery properties 29 + - charge-term-current-microamp: current for charge termination phase. 30 + - constant-charge-voltage-max-microvolt: maximum constant input voltage. 31 + See Documentation/devicetree/bindings/power/supply/battery.yaml 32 + 33 + additionalProperties: false 34 + 35 + examples: 36 + - | 37 + bat: battery { 38 + compatible = "simple-battery"; 39 + charge-term-current-microamp = <120000>; 40 + constant-charge-voltage-max-microvolt = <4350000>; 41 + }; 42 + 43 + pmic { 44 + #address-cells = <1>; 45 + #size-cells = <0>; 46 + 47 + battery@a00 { 48 + compatible = "sprd,sc2731-charger"; 49 + reg = <0x0>; 50 + phys = <&ssphy>; 51 + monitored-battery = <&bat>; 52 + }; 53 + };
-40
Documentation/devicetree/bindings/power/supply/sc2731_charger.txt
··· 1 - Spreadtrum SC2731 PMIC battery charger binding 2 - 3 - Required properties: 4 - - compatible: Should be "sprd,sc2731-charger". 5 - - reg: Address offset of charger register. 6 - - phys: Contains a phandle to the USB phy. 7 - 8 - Optional Properties: 9 - - monitored-battery: phandle of battery characteristics devicetree node. 10 - The charger uses the following battery properties: 11 - - charge-term-current-microamp: current for charge termination phase. 12 - - constant-charge-voltage-max-microvolt: maximum constant input voltage. 13 - See Documentation/devicetree/bindings/power/supply/battery.txt 14 - 15 - Example: 16 - 17 - bat: battery { 18 - compatible = "simple-battery"; 19 - charge-term-current-microamp = <120000>; 20 - constant-charge-voltage-max-microvolt = <4350000>; 21 - ...... 22 - }; 23 - 24 - sc2731_pmic: pmic@0 { 25 - compatible = "sprd,sc2731"; 26 - reg = <0>; 27 - spi-max-frequency = <26000000>; 28 - interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; 29 - interrupt-controller; 30 - #interrupt-cells = <2>; 31 - #address-cells = <1>; 32 - #size-cells = <0>; 33 - 34 - charger@0 { 35 - compatible = "sprd,sc2731-charger"; 36 - reg = <0x0>; 37 - phys = <&ssphy>; 38 - monitored-battery = <&bat>; 39 - }; 40 - };
-59
Documentation/devicetree/bindings/power/supply/sc27xx-fg.txt
··· 1 - Spreadtrum SC27XX PMICs Fuel Gauge Unit Power Supply Bindings 2 - 3 - Required properties: 4 - - compatible: Should be one of the following: 5 - "sprd,sc2720-fgu", 6 - "sprd,sc2721-fgu", 7 - "sprd,sc2723-fgu", 8 - "sprd,sc2730-fgu", 9 - "sprd,sc2731-fgu". 10 - - reg: The address offset of fuel gauge unit. 11 - - battery-detect-gpios: GPIO for battery detection. 12 - - io-channels: Specify the IIO ADC channels to get temperature and charge voltage. 13 - - io-channel-names: Should be "bat-temp" or "charge-vol". 14 - - nvmem-cells: A phandle to the calibration cells provided by eFuse device. 15 - - nvmem-cell-names: Should be "fgu_calib". 16 - - sprd,calib-resistance-micro-ohms: Specify the real resistance of coulomb counter 17 - chip in micro Ohms. 18 - - monitored-battery: Phandle of battery characteristics devicetree node. 19 - See Documentation/devicetree/bindings/power/supply/battery.txt 20 - 21 - Example: 22 - 23 - bat: battery { 24 - compatible = "simple-battery"; 25 - charge-full-design-microamp-hours = <1900000>; 26 - constant-charge-voltage-max-microvolt = <4350000>; 27 - ocv-capacity-celsius = <20>; 28 - ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, 29 - <4022000 85>, <3983000 80>, <3949000 75>, 30 - <3917000 70>, <3889000 65>, <3864000 60>, 31 - <3835000 55>, <3805000 50>, <3787000 45>, 32 - <3777000 40>, <3773000 35>, <3770000 30>, 33 - <3765000 25>, <3752000 20>, <3724000 15>, 34 - <3680000 10>, <3605000 5>, <3400000 0>; 35 - ...... 36 - }; 37 - 38 - sc2731_pmic: pmic@0 { 39 - compatible = "sprd,sc2731"; 40 - reg = <0>; 41 - spi-max-frequency = <26000000>; 42 - interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; 43 - interrupt-controller; 44 - #interrupt-cells = <2>; 45 - #address-cells = <1>; 46 - #size-cells = <0>; 47 - 48 - fgu@a00 { 49 - compatible = "sprd,sc2731-fgu"; 50 - reg = <0xa00>; 51 - battery-detect-gpios = <&pmic_eic 9 GPIO_ACTIVE_HIGH>; 52 - io-channels = <&pmic_adc 5>, <&pmic_adc 14>; 53 - io-channel-names = "bat-temp", "charge-vol"; 54 - nvmem-cells = <&fgu_calib>; 55 - nvmem-cell-names = "fgu_calib"; 56 - monitored-battery = <&bat>; 57 - sprd,calib-resistance-micro-ohms = <21500>; 58 - }; 59 - };
+98
Documentation/devicetree/bindings/power/supply/sc27xx-fg.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/sc27xx-fg.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Spreadtrum SC27XX PMICs Fuel Gauge Unit Power Supply Bindings 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + enum: 18 + - sprd,sc2720-fgu 19 + - sprd,sc2721-fgu 20 + - sprd,sc2723-fgu 21 + - sprd,sc2730-fgu 22 + - sprd,sc2731-fgu 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + battery-detect-gpios: 28 + maxItems: 1 29 + 30 + io-channels: 31 + items: 32 + - description: Battery Temperature ADC 33 + - description: Battery Charge Voltage ADC 34 + 35 + io-channel-names: 36 + items: 37 + - const: bat-temp 38 + - const: charge-vol 39 + 40 + nvmem-cells: 41 + maxItems: 1 42 + description: Calibration cells provided by eFuse device 43 + 44 + nvmem-cell-names: 45 + const: fgu_calib 46 + 47 + sprd,calib-resistance-micro-ohms: 48 + description: real resistance of coulomb counter chip in micro Ohms 49 + 50 + monitored-battery: true 51 + 52 + required: 53 + - compatible 54 + - reg 55 + - battery-detect-gpios 56 + - io-channels 57 + - io-channel-names 58 + - nvmem-cells 59 + - nvmem-cell-names 60 + - sprd,calib-resistance-micro-ohms 61 + - monitored-battery 62 + 63 + additionalProperties: false 64 + 65 + examples: 66 + - | 67 + #include <dt-bindings/gpio/gpio.h> 68 + bat: battery { 69 + compatible = "simple-battery"; 70 + charge-full-design-microamp-hours = <1900000>; 71 + constant-charge-voltage-max-microvolt = <4350000>; 72 + ocv-capacity-celsius = <20>; 73 + ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, 74 + <4022000 85>, <3983000 80>, <3949000 75>, 75 + <3917000 70>, <3889000 65>, <3864000 60>, 76 + <3835000 55>, <3805000 50>, <3787000 45>, 77 + <3777000 40>, <3773000 35>, <3770000 30>, 78 + <3765000 25>, <3752000 20>, <3724000 15>, 79 + <3680000 10>, <3605000 5>, <3400000 0>; 80 + // ... 81 + }; 82 + 83 + pmic { 84 + #address-cells = <1>; 85 + #size-cells = <0>; 86 + 87 + battery@a00 { 88 + compatible = "sprd,sc2731-fgu"; 89 + reg = <0xa00>; 90 + battery-detect-gpios = <&pmic_eic 9 GPIO_ACTIVE_HIGH>; 91 + io-channels = <&pmic_adc 5>, <&pmic_adc 14>; 92 + io-channel-names = "bat-temp", "charge-vol"; 93 + nvmem-cells = <&fgu_calib>; 94 + nvmem-cell-names = "fgu_calib"; 95 + monitored-battery = <&bat>; 96 + sprd,calib-resistance-micro-ohms = <21500>; 97 + }; 98 + };
+34
Documentation/devicetree/bindings/power/supply/stericsson,ab8500-battery.txt
··· 1 + AB85000 PMIC contains a node, which contains shared 2 + information about the battery connected to the PMIC. 3 + The node has no compatible property. 4 + 5 + Properties of this node are: 6 + 7 + thermistor-on-batctrl: 8 + A boolean value indicating thermistor interface to battery 9 + 10 + Note: 11 + 'btemp' and 'batctrl' are the pins interfaced for battery temperature 12 + measurement, 'btemp' signal is used when NTC(negative temperature 13 + coefficient) resister is interfaced external to battery whereas 14 + 'batctrl' pin is used when NTC resister is internal to battery. 15 + 16 + Example: 17 + ab8500_battery: ab8500_battery { 18 + thermistor-on-batctrl; 19 + }; 20 + indicates: NTC resister is internal to battery, 'batctrl' is used 21 + for thermal measurement. 22 + 23 + The absence of property 'thermal-on-batctrl' indicates 24 + NTC resister is external to battery and 'btemp' signal is used 25 + for thermal measurement. 26 + 27 + battery-type: 28 + This shall be the battery manufacturing technology type, 29 + allowed types are: 30 + "UNKNOWN" "NiMH" "LION" "LIPO" "LiFe" "NiCd" "LiMn" 31 + Example: 32 + ab8500_battery: ab8500_battery { 33 + stericsson,battery-type = "LIPO"; 34 + }
+73
Documentation/devicetree/bindings/power/supply/stericsson,ab8500-btemp.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/stericsson,ab8500-btemp.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: AB8500 Battery Temperature Monitor 9 + 10 + maintainers: 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + const: stericsson,ab8500-btemp 19 + 20 + battery: 21 + $ref: /schemas/types.yaml#/definitions/phandle 22 + description: phandle to battery node 23 + 24 + interrupts: 25 + maxItems: 5 26 + 27 + interrupt-names: 28 + items: 29 + - const: BAT_CTRL_INDB 30 + - const: BTEMP_LOW 31 + - const: BTEMP_HIGH 32 + - const: BTEMP_LOW_MEDIUM 33 + - const: BTEMP_MEDIUM_HIGH 34 + 35 + io-channels: 36 + maxItems: 2 37 + 38 + io-channel-names: 39 + items: 40 + - const: btemp_ball 41 + - const: bat_ctrl 42 + 43 + required: 44 + - compatible 45 + - battery 46 + - interrupts 47 + - interrupt-names 48 + - io-channels 49 + - io-channel-names 50 + 51 + additionalProperties: false 52 + 53 + examples: 54 + - | 55 + #include <dt-bindings/interrupt-controller/irq.h> 56 + pmic { 57 + battery-temperature { 58 + compatible = "stericsson,ab8500-btemp"; 59 + battery = <&ab8500_battery>; 60 + interrupts = <20 IRQ_TYPE_LEVEL_HIGH>, 61 + <80 IRQ_TYPE_LEVEL_HIGH>, 62 + <83 IRQ_TYPE_LEVEL_HIGH>, 63 + <81 IRQ_TYPE_LEVEL_HIGH>, 64 + <82 IRQ_TYPE_LEVEL_HIGH>; 65 + interrupt-names = "BAT_CTRL_INDB", 66 + "BTEMP_LOW", 67 + "BTEMP_HIGH", 68 + "BTEMP_LOW_MEDIUM", 69 + "BTEMP_MEDIUM_HIGH"; 70 + io-channels = <&gpadc 0x02>, <&gpadc 0x01>; 71 + io-channel-names = "btemp_ball", "bat_ctrl"; 72 + }; 73 + };
+37
Documentation/devicetree/bindings/power/supply/stericsson,ab8500-chargalg.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/stericsson,ab8500-chargalg.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: AB8500 Charging Algorithm 9 + 10 + maintainers: 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + const: stericsson,ab8500-chargalg 19 + 20 + battery: 21 + $ref: /schemas/types.yaml#/definitions/phandle 22 + description: phandle to battery node 23 + 24 + required: 25 + - compatible 26 + - battery 27 + 28 + additionalProperties: false 29 + 30 + examples: 31 + - | 32 + pmic { 33 + charging-algorithm { 34 + compatible = "stericsson,ab8500-chargalg"; 35 + battery = <&ab8500_battery>; 36 + }; 37 + };
+123
Documentation/devicetree/bindings/power/supply/stericsson,ab8500-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/stericsson,ab8500-charger.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: AB8500 Charger 9 + 10 + maintainers: 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + const: stericsson,ab8500-charger 19 + 20 + battery: 21 + $ref: /schemas/types.yaml#/definitions/phandle 22 + description: phandle to battery node 23 + 24 + vddadc-supply: 25 + description: Supply for USB and Main charger 26 + 27 + autopower_cfg: 28 + type: boolean 29 + description: automatic poweron after powerloss 30 + 31 + interrupts: 32 + maxItems: 14 33 + 34 + interrupt-names: 35 + items: 36 + - const: MAIN_CH_UNPLUG_DET 37 + - const: MAIN_CHARGE_PLUG_DET 38 + - const: MAIN_EXT_CH_NOT_OK 39 + - const: MAIN_CH_TH_PROT_R 40 + - const: MAIN_CH_TH_PROT_F 41 + - const: VBUS_DET_F 42 + - const: VBUS_DET_R 43 + - const: USB_LINK_STATUS 44 + - const: USB_CH_TH_PROT_R 45 + - const: USB_CH_TH_PROT_F 46 + - const: USB_CHARGER_NOT_OKR 47 + - const: VBUS_OVV 48 + - const: CH_WD_EXP 49 + - const: VBUS_CH_DROP_END 50 + 51 + io-channels: 52 + minItems: 2 53 + maxItems: 4 54 + 55 + io-channel-names: 56 + oneOf: 57 + - items: 58 + - const: main_charger_v 59 + - const: main_charger_c 60 + - const: vbus_v 61 + - const: usb_charger_c 62 + - items: 63 + - const: vbus_v 64 + - const: usb_charger_c 65 + 66 + 67 + required: 68 + - compatible 69 + - battery 70 + - vddadc-supply 71 + - interrupts 72 + - interrupt-names 73 + - io-channels 74 + - io-channel-names 75 + 76 + additionalProperties: false 77 + 78 + examples: 79 + - | 80 + #include <dt-bindings/interrupt-controller/irq.h> 81 + pmic { 82 + charger { 83 + compatible = "stericsson,ab8500-charger"; 84 + battery = <&ab8500_battery>; 85 + vddadc-supply = <&ab8500_ldo_tvout_reg>; 86 + interrupts = <10 IRQ_TYPE_LEVEL_HIGH>, 87 + <11 IRQ_TYPE_LEVEL_HIGH>, 88 + <0 IRQ_TYPE_LEVEL_HIGH>, 89 + <107 IRQ_TYPE_LEVEL_HIGH>, 90 + <106 IRQ_TYPE_LEVEL_HIGH>, 91 + <14 IRQ_TYPE_LEVEL_HIGH>, 92 + <15 IRQ_TYPE_LEVEL_HIGH>, 93 + <79 IRQ_TYPE_LEVEL_HIGH>, 94 + <105 IRQ_TYPE_LEVEL_HIGH>, 95 + <104 IRQ_TYPE_LEVEL_HIGH>, 96 + <89 IRQ_TYPE_LEVEL_HIGH>, 97 + <22 IRQ_TYPE_LEVEL_HIGH>, 98 + <21 IRQ_TYPE_LEVEL_HIGH>, 99 + <16 IRQ_TYPE_LEVEL_HIGH>; 100 + interrupt-names = "MAIN_CH_UNPLUG_DET", 101 + "MAIN_CHARGE_PLUG_DET", 102 + "MAIN_EXT_CH_NOT_OK", 103 + "MAIN_CH_TH_PROT_R", 104 + "MAIN_CH_TH_PROT_F", 105 + "VBUS_DET_F", 106 + "VBUS_DET_R", 107 + "USB_LINK_STATUS", 108 + "USB_CH_TH_PROT_R", 109 + "USB_CH_TH_PROT_F", 110 + "USB_CHARGER_NOT_OKR", 111 + "VBUS_OVV", 112 + "CH_WD_EXP", 113 + "VBUS_CH_DROP_END"; 114 + io-channels = <&gpadc 0x03>, 115 + <&gpadc 0x0a>, 116 + <&gpadc 0x09>, 117 + <&gpadc 0x0b>; 118 + io-channel-names = "main_charger_v", 119 + "main_charger_c", 120 + "vbus_v", 121 + "usb_charger_c"; 122 + }; 123 + };
+72
Documentation/devicetree/bindings/power/supply/stericsson,ab8500-fg.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # Copyright (C) 2021 Sebastian Reichel 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/power/supply/stericsson,ab8500-fg.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: AB8500 Fuel Gauge 9 + 10 + maintainers: 11 + - Sebastian Reichel <sre@kernel.org> 12 + 13 + allOf: 14 + - $ref: power-supply.yaml# 15 + 16 + properties: 17 + compatible: 18 + const: stericsson,ab8500-fg 19 + 20 + battery: 21 + $ref: /schemas/types.yaml#/definitions/phandle 22 + description: phandle to battery node 23 + 24 + interrupts: 25 + maxItems: 5 26 + 27 + interrupt-names: 28 + items: 29 + - const: NCONV_ACCU 30 + - const: BATT_OVV 31 + - const: LOW_BAT_F 32 + - const: CC_INT_CALIB 33 + - const: CCEOC 34 + 35 + io-channels: 36 + maxItems: 1 37 + 38 + io-channel-names: 39 + items: 40 + - const: main_bat_v 41 + 42 + required: 43 + - compatible 44 + - battery 45 + - interrupts 46 + - interrupt-names 47 + - io-channels 48 + - io-channel-names 49 + 50 + additionalProperties: false 51 + 52 + examples: 53 + - | 54 + #include <dt-bindings/interrupt-controller/irq.h> 55 + pmic { 56 + fuel-gauge { 57 + compatible = "stericsson,ab8500-fg"; 58 + battery = <&ab8500_battery>; 59 + interrupts = <24 IRQ_TYPE_LEVEL_HIGH>, 60 + <8 IRQ_TYPE_LEVEL_HIGH>, 61 + <28 IRQ_TYPE_LEVEL_HIGH>, 62 + <27 IRQ_TYPE_LEVEL_HIGH>, 63 + <26 IRQ_TYPE_LEVEL_HIGH>; 64 + interrupt-names = "NCONV_ACCU", 65 + "BATT_OVV", 66 + "LOW_BAT_F", 67 + "CC_INT_CALIB", 68 + "CCEOC"; 69 + io-channels = <&gpadc 0x08>; 70 + io-channel-names = "main_bat_v"; 71 + }; 72 + };
-39
Documentation/devicetree/bindings/power/supply/ti,bq24735.txt
··· 1 - TI BQ24735 Charge Controller 2 - ~~~~~~~~~~ 3 - 4 - Required properties : 5 - - compatible : "ti,bq24735" 6 - 7 - Optional properties : 8 - - interrupts : Specify the interrupt to be used to trigger when the AC 9 - adapter is either plugged in or removed. 10 - - ti,ac-detect-gpios : This GPIO is optionally used to read the AC adapter 11 - status. This is a Host GPIO that is configured as an input and connected 12 - to the ACOK pin on the bq24735. Note: for backwards compatibility reasons, 13 - the GPIO must be active on AC adapter absence despite ACOK being active 14 - (high) on AC adapter presence. 15 - - ti,charge-current : Used to control and set the charging current. This value 16 - must be between 128mA and 8.128A with a 64mA step resolution. The POR value 17 - is 0x0000h. This number is in mA (e.g. 8192), see spec for more information 18 - about the ChargeCurrent (0x14h) register. 19 - - ti,charge-voltage : Used to control and set the charging voltage. This value 20 - must be between 1.024V and 19.2V with a 16mV step resolution. The POR value 21 - is 0x0000h. This number is in mV (e.g. 19200), see spec for more information 22 - about the ChargeVoltage (0x15h) register. 23 - - ti,input-current : Used to control and set the charger input current. This 24 - value must be between 128mA and 8.064A with a 128mA step resolution. The 25 - POR value is 0x1000h. This number is in mA (e.g. 8064), see the spec for 26 - more information about the InputCurrent (0x3fh) register. 27 - - ti,external-control : Indicates that the charger is configured externally 28 - and that the host should not attempt to enable/disable charging or set the 29 - charge voltage/current. 30 - - poll-interval : In case 'interrupts' is not specified, poll AC adapter 31 - presence with this interval (milliseconds). 32 - 33 - Example: 34 - 35 - bq24735@9 { 36 - compatible = "ti,bq24735"; 37 - reg = <0x9>; 38 - ti,ac-detect-gpios = <&gpio 72 0x1>; 39 - }
+90
Documentation/devicetree/bindings/power/supply/ti,lp8727.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/power/supply/ti,lp8727.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Binding for TI/National Semiconductor LP8727 Charger 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: ti,lp8727 18 + 19 + reg: 20 + const: 0x27 21 + 22 + interrupts: 23 + maxItems: 1 24 + 25 + debounce-ms: 26 + description: interrupt debounce time in ms 27 + 28 + patternProperties: 29 + '^(ac|usb)$': 30 + type: object 31 + description: USB/AC charging parameters 32 + properties: 33 + charger-type: 34 + enum: 35 + - ac 36 + - usb 37 + 38 + eoc-level: 39 + $ref: /schemas/types.yaml#/definitions/uint8 40 + minimum: 0 41 + maximum: 6 42 + description: | 43 + End of Charge Percentage with the following mapping: 44 + 0 = 5%, 1 = 10%, 2 = 16%, 3 = 20%, 4 = 25%, 5 = 33%, 6 = 50% 45 + 46 + charging-current: 47 + $ref: /schemas/types.yaml#/definitions/uint8 48 + minimum: 0 49 + maximum: 9 50 + description: | 51 + Charging current with the following mapping: 52 + 0 = 90mA, 1 = 100mA, 2 = 400mA, 3 = 450mA, 4 = 500mA, 5 = 600mA, 53 + 6 = 700mA, 7 = 800mA, 8 = 900mA, 9 = 1000mA 54 + 55 + required: 56 + - compatible 57 + - reg 58 + 59 + additionalProperties: false 60 + 61 + examples: 62 + - | 63 + #include <dt-bindings/interrupt-controller/irq.h> 64 + i2c0 { 65 + #address-cells = <1>; 66 + #size-cells = <0>; 67 + 68 + lp8727: charger@27 { 69 + compatible = "ti,lp8727"; 70 + reg = <0x27>; 71 + interrupt-parent = <&gpio5>; 72 + interrupts = <6 IRQ_TYPE_EDGE_FALLING>; 73 + debounce-ms = <300>; 74 + 75 + /* AC charger: 5% EOC and 500mA charging current */ 76 + ac { 77 + charger-type = "ac"; 78 + eoc-level = /bits/ 8 <0>; 79 + charging-current = /bits/ 8 <4>; 80 + }; 81 + 82 + /* USB charger: 10% EOC and 400mA charging current */ 83 + usb { 84 + charger-type = "usb"; 85 + eoc-level = /bits/ 8 <1>; 86 + charging-current = /bits/ 8 <2>; 87 + }; 88 + }; 89 + }; 90 +
+36
Documentation/devicetree/bindings/power/supply/tps65090-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/tps65090-charger.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: TPS65090 Frontend PMU with Switchmode Charger 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: ti,tps65090-charger 18 + 19 + ti,enable-low-current-chrg: 20 + type: boolean 21 + description: | 22 + Enables charging when a low current is detected while the default logic is to stop charging. 23 + 24 + required: 25 + - compatible 26 + 27 + additionalProperties: false 28 + 29 + examples: 30 + - | 31 + pmic { 32 + charger { 33 + compatible = "ti,tps65090-charger"; 34 + ti,enable-low-current-chrg; 35 + }; 36 + };
-17
Documentation/devicetree/bindings/power/supply/tps65090.txt
··· 1 - TPS65090 Frontend PMU with Switchmode Charger 2 - 3 - Required Properties: 4 - -compatible: "ti,tps65090-charger" 5 - 6 - Optional Properties: 7 - -ti,enable-low-current-chrg: Enables charging when a low current is detected 8 - while the default logic is to stop charging. 9 - 10 - This node is a subnode of the tps65090 PMIC. 11 - 12 - Example: 13 - 14 - tps65090-charger { 15 - compatible = "ti,tps65090-charger"; 16 - ti,enable-low-current-chrg; 17 - };
+43
Documentation/devicetree/bindings/power/supply/tps65217-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/tps65217-charger.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: TPS65217 Charger 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + allOf: 13 + - $ref: power-supply.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: ti,tps65217-charger 18 + 19 + interrupts: 20 + minItems: 2 21 + maxItems: 2 22 + 23 + interrupt-names: 24 + items: 25 + - const: USB 26 + - const: AC 27 + 28 + required: 29 + - compatible 30 + - interrupts 31 + - interrupt-names 32 + 33 + additionalProperties: false 34 + 35 + examples: 36 + - | 37 + pmic { 38 + charger { 39 + compatible = "ti,tps65217-charger"; 40 + interrupts = <0>, <1>; 41 + interrupt-names = "USB", "AC"; 42 + }; 43 + };
-17
Documentation/devicetree/bindings/power/supply/tps65217_charger.txt
··· 1 - TPS65217 Charger 2 - 3 - Required Properties: 4 - -compatible: "ti,tps65217-charger" 5 - -interrupts: TPS65217 interrupt numbers for the AC and USB charger input change. 6 - Should be <0> for the USB charger and <1> for the AC adapter. 7 - -interrupt-names: Should be "USB" and "AC" 8 - 9 - This node is a subnode of the tps65217 PMIC. 10 - 11 - Example: 12 - 13 - tps65217-charger { 14 - compatible = "ti,tps65217-charger"; 15 - interrupts = <0>, <1>; 16 - interrupt-names = "USB", "AC"; 17 - };
-30
Documentation/devicetree/bindings/power/supply/twl-charger.txt
··· 1 - TWL BCI (Battery Charger Interface) 2 - 3 - The battery charger needs to interact with the USB phy in order 4 - to know when charging is permissible, and when there is a connection 5 - or disconnection. 6 - 7 - The choice of phy cannot be configured at a hardware level, so there 8 - is no value in explicit configuration in device-tree. Rather 9 - if there is a sibling of the BCI node which is compatible with 10 - "ti,twl4030-usb", then that is used to determine when and how 11 - use USB power for charging. 12 - 13 - Required properties: 14 - - compatible: 15 - - "ti,twl4030-bci" 16 - - interrupts: two interrupt lines from the TWL SIH (secondary 17 - interrupt handler) - interrupts 9 and 2. 18 - 19 - Optional properties: 20 - - ti,bb-uvolt: microvolts for charging the backup battery. 21 - - ti,bb-uamp: microamps for charging the backup battery. 22 - 23 - Examples: 24 - 25 - bci { 26 - compatible = "ti,twl4030-bci"; 27 - interrupts = <9>, <2>; 28 - ti,bb-uvolt = <3200000>; 29 - ti,bb-uamp = <150>; 30 - };
+68
Documentation/devicetree/bindings/power/supply/twl4030-charger.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/twl4030-charger.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: TWL4030 BCI (Battery Charger Interface) 8 + 9 + description: | 10 + The battery charger needs to interact with the USB phy in order to know when 11 + charging is permissible, and when there is a connection or disconnection. 12 + 13 + The choice of phy cannot be configured at a hardware level, so there is no 14 + value in explicit configuration in device-tree. Rather if there is a sibling 15 + of the BCI node which is compatible with "ti,twl4030-usb", then that is used 16 + to determine when and how use USB power for charging. 17 + 18 + maintainers: 19 + - Sebastian Reichel <sre@kernel.org> 20 + 21 + allOf: 22 + - $ref: power-supply.yaml# 23 + 24 + properties: 25 + compatible: 26 + const: ti,twl4030-bci 27 + 28 + interrupts: 29 + minItems: 2 30 + maxItems: 2 31 + 32 + ti,bb-uvolt: 33 + $ref: /schemas/types.yaml#/definitions/uint32 34 + description: microvolts for charging the backup battery 35 + 36 + ti,bb-uamp: 37 + $ref: /schemas/types.yaml#/definitions/uint32 38 + description: microamps for charging the backup battery 39 + 40 + io-channels: 41 + items: 42 + - description: Accessory Charger Voltage Channel 43 + 44 + io-channel-names: 45 + items: 46 + - const: vac 47 + 48 + bci3v1-supply: 49 + description: 3.1V USB regulator 50 + 51 + required: 52 + - compatible 53 + - interrupts 54 + 55 + additionalProperties: false 56 + 57 + examples: 58 + - | 59 + pmic { 60 + charger { 61 + compatible = "ti,twl4030-bci"; 62 + interrupts = <9>, <2>; 63 + ti,bb-uvolt = <3200000>; 64 + ti,bb-uamp = <150>; 65 + io-channels = <&twl_madc 11>; 66 + io-channel-names = "vac"; 67 + }; 68 + };
+32
Documentation/devicetree/bindings/power/supply/x-powers,axp20x-ac-power-supply.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/x-powers,axp20x-ac-power-supply.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: AXP20x AC power-supply 8 + 9 + description: | 10 + The AXP20X can read the current current and voltage supplied by AC by 11 + reading ADC channels from the AXP20X ADC. The AXP22X is only able to 12 + tell if an AC power supply is present and usable. AXP813/AXP803 are 13 + able to limit current and supply voltage 14 + 15 + maintainers: 16 + - Chen-Yu Tsai <wens@csie.org> 17 + - Sebastian Reichel <sre@kernel.org> 18 + 19 + allOf: 20 + - $ref: power-supply.yaml# 21 + 22 + properties: 23 + compatible: 24 + enum: 25 + - x-powers,axp202-ac-power-supply 26 + - x-powers,axp221-ac-power-supply 27 + - x-powers,axp813-ac-power-supply 28 + 29 + required: 30 + - compatible 31 + 32 + additionalProperties: false
+30
Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/x-powers,axp20x-battery-power-supply.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: AXP20x Battery power-supply 8 + 9 + description: | 10 + The supported devices can read the battery voltage, charge and discharge 11 + currents of the battery by reading ADC channels from the ADC. 12 + 13 + maintainers: 14 + - Chen-Yu Tsai <wens@csie.org> 15 + - Sebastian Reichel <sre@kernel.org> 16 + 17 + allOf: 18 + - $ref: power-supply.yaml# 19 + 20 + properties: 21 + compatible: 22 + enum: 23 + - x-powers,axp209-battery-power-supply 24 + - x-powers,axp221-battery-power-supply 25 + - x-powers,axp813-battery-power-supply 26 + 27 + required: 28 + - compatible 29 + 30 + additionalProperties: false
+33
Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/power/supply/x-powers,axp20x-usb-power-supply.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: AXP20x USB power-supply 8 + 9 + description: | 10 + The AXP223 PMIC shares most of its behaviour with the AXP221 but has slight 11 + variations such as the former being able to set the VBUS power supply max 12 + current to 100mA, unlike the latter. 13 + 14 + maintainers: 15 + - Chen-Yu Tsai <wens@csie.org> 16 + - Sebastian Reichel <sre@kernel.org> 17 + 18 + allOf: 19 + - $ref: power-supply.yaml# 20 + 21 + properties: 22 + compatible: 23 + enum: 24 + - x-powers,axp202-usb-power-supply 25 + - x-powers,axp221-usb-power-supply 26 + - x-powers,axp223-usb-power-supply 27 + - x-powers,axp813-usb-power-supply 28 + 29 + 30 + required: 31 + - compatible 32 + 33 + additionalProperties: false
+1 -1
Documentation/power/power_supply_class.rst
··· 233 233 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 234 234 Drivers should call power_supply_get_battery_info() to obtain battery 235 235 characteristics from a devicetree battery node, defined in 236 - Documentation/devicetree/bindings/power/supply/battery.txt. This is 236 + Documentation/devicetree/bindings/power/supply/battery.yaml. This is 237 237 implemented in drivers/power/supply/bq27xxx_battery.c. 238 238 239 239 Properties in struct power_supply_battery_info and their counterparts in the
+16 -1
MAINTAINERS
··· 10175 10175 LEGO MINDSTORMS EV3 10176 10176 R: David Lechner <david@lechnology.com> 10177 10177 S: Maintained 10178 - F: Documentation/devicetree/bindings/power/supply/lego_ev3_battery.txt 10178 + F: Documentation/devicetree/bindings/power/supply/lego,ev3-battery.yaml 10179 10179 F: arch/arm/boot/dts/da850-lego-ev3.dts 10180 10180 F: drivers/power/supply/lego_ev3_battery.c 10181 10181 ··· 12001 12001 F: drivers/scsi/smartpqi/smartpqi*.[ch] 12002 12002 F: include/linux/cciss*.h 12003 12003 F: include/uapi/linux/cciss*.h 12004 + 12005 + MICROSOFT SURFACE BATTERY AND AC DRIVERS 12006 + M: Maximilian Luz <luzmaximilian@gmail.com> 12007 + L: linux-pm@vger.kernel.org 12008 + L: platform-driver-x86@vger.kernel.org 12009 + S: Maintained 12010 + F: drivers/power/supply/surface_battery.c 12011 + F: drivers/power/supply/surface_charger.c 12004 12012 12005 12013 MICROSOFT SURFACE DTX DRIVER 12006 12014 M: Maximilian Luz <luzmaximilian@gmail.com> ··· 15861 15853 S: Supported 15862 15854 W: http://www.ibm.com/developerworks/linux/linux390/ 15863 15855 F: drivers/s390/scsi/zfcp_* 15856 + 15857 + S3C ADC BATTERY DRIVER 15858 + M: Krzysztof Kozlowski <krzk@kernel.org> 15859 + L: linux-samsung-soc@vger.kernel.org 15860 + S: Odd Fixes 15861 + F: drivers/power/supply/s3c_adc_battery.c 15862 + F: include/linux/s3c_adc_battery.h 15864 15863 15865 15864 S3C24XX SD/MMC Driver 15866 15865 M: Ben Dooks <ben-linux@fluff.org>
+8 -9
drivers/mfd/ab8500-core.c
··· 19 19 #include <linux/mfd/core.h> 20 20 #include <linux/mfd/abx500.h> 21 21 #include <linux/mfd/abx500/ab8500.h> 22 - #include <linux/mfd/abx500/ab8500-bm.h> 23 22 #include <linux/mfd/dbx500-prcmu.h> 24 23 #include <linux/of.h> 25 24 #include <linux/of_device.h> ··· 608 609 } 609 610 610 611 static const struct mfd_cell ab8500_bm_devs[] = { 611 - MFD_CELL_OF("ab8500-charger", NULL, &ab8500_bm_data, 612 - sizeof(ab8500_bm_data), 0, "stericsson,ab8500-charger"), 613 - MFD_CELL_OF("ab8500-btemp", NULL, &ab8500_bm_data, 614 - sizeof(ab8500_bm_data), 0, "stericsson,ab8500-btemp"), 615 - MFD_CELL_OF("ab8500-fg", NULL, &ab8500_bm_data, 616 - sizeof(ab8500_bm_data), 0, "stericsson,ab8500-fg"), 617 - MFD_CELL_OF("ab8500-chargalg", NULL, &ab8500_bm_data, 618 - sizeof(ab8500_bm_data), 0, "stericsson,ab8500-chargalg"), 612 + MFD_CELL_OF("ab8500-charger", NULL, NULL, 0, 0, 613 + "stericsson,ab8500-charger"), 614 + MFD_CELL_OF("ab8500-btemp", NULL, NULL, 0, 0, 615 + "stericsson,ab8500-btemp"), 616 + MFD_CELL_OF("ab8500-fg", NULL, NULL, 0, 0, 617 + "stericsson,ab8500-fg"), 618 + MFD_CELL_OF("ab8500-chargalg", NULL, NULL, 0, 0, 619 + "stericsson,ab8500-chargalg"), 619 620 }; 620 621 621 622 static const struct mfd_cell ab8500_devs[] = {
+1 -1
drivers/power/reset/Makefile
··· 11 11 obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o 12 12 obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o 13 13 obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o 14 - obj-${CONFIG_POWER_RESET_LINKSTATION} += linkstation-poweroff.o 14 + obj-$(CONFIG_POWER_RESET_LINKSTATION) += linkstation-poweroff.o 15 15 obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o 16 16 obj-$(CONFIG_POWER_RESET_MT6323) += mt6323-poweroff.o 17 17 obj-$(CONFIG_POWER_RESET_OXNAS) += oxnas-restart.o
+2 -2
drivers/power/reset/at91-reset.c
··· 192 192 if (!reset) 193 193 return -ENOMEM; 194 194 195 - reset->rstc_base = of_iomap(pdev->dev.of_node, 0); 195 + reset->rstc_base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL); 196 196 if (!reset->rstc_base) { 197 197 dev_err(&pdev->dev, "Could not map reset controller address\n"); 198 198 return -ENODEV; ··· 202 202 /* we need to shutdown the ddr controller, so get ramc base */ 203 203 for_each_matching_node_and_match(np, at91_ramc_of_match, &match) { 204 204 reset->ramc_lpr = (u32)match->data; 205 - reset->ramc_base[idx] = of_iomap(np, 0); 205 + reset->ramc_base[idx] = devm_of_iomap(&pdev->dev, np, 0, NULL); 206 206 if (!reset->ramc_base[idx]) { 207 207 dev_err(&pdev->dev, "Could not map ram controller address\n"); 208 208 of_node_put(np);
+3 -2
drivers/power/reset/hisi-reboot.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 - * Hisilicon SoC reset code 3 + * HiSilicon SoC reset code 4 4 * 5 - * Copyright (c) 2014 Hisilicon Ltd. 5 + * Copyright (c) 2014 HiSilicon Ltd. 6 6 * Copyright (c) 2014 Linaro Ltd. 7 7 * 8 8 * Author: Haojian Zhuang <haojian.zhuang@linaro.org> ··· 68 68 { .compatible = "hisilicon,sysctrl" }, 69 69 {} 70 70 }; 71 + MODULE_DEVICE_TABLE(of, hisi_reboot_of_match); 71 72 72 73 static struct platform_driver hisi_reboot_driver = { 73 74 .probe = hisi_reboot_probe,
+8
drivers/power/reset/ltc2952-poweroff.c
··· 55 55 #include <linux/mod_devicetable.h> 56 56 #include <linux/gpio/consumer.h> 57 57 #include <linux/reboot.h> 58 + #include <linux/property.h> 58 59 59 60 struct ltc2952_poweroff { 60 61 struct hrtimer timer_trigger; ··· 173 172 static int ltc2952_poweroff_init(struct platform_device *pdev) 174 173 { 175 174 int ret; 175 + u32 trigger_delay_ms; 176 176 struct ltc2952_poweroff *data = platform_get_drvdata(pdev); 177 177 178 178 ltc2952_poweroff_default(data); 179 + 180 + if (!device_property_read_u32(&pdev->dev, "trigger-delay-ms", 181 + &trigger_delay_ms)) { 182 + data->trigger_delay = ktime_set(trigger_delay_ms / MSEC_PER_SEC, 183 + (trigger_delay_ms % MSEC_PER_SEC) * NSEC_PER_MSEC); 184 + } 179 185 180 186 data->gpio_watchdog = devm_gpiod_get(&pdev->dev, "watchdog", 181 187 GPIOD_OUT_LOW);
+1
drivers/power/reset/restart-poweroff.c
··· 45 45 { .compatible = "restart-poweroff", }, 46 46 {}, 47 47 }; 48 + MODULE_DEVICE_TABLE(of, of_restart_poweroff_match); 48 49 49 50 static struct platform_driver restart_poweroff_driver = { 50 51 .probe = restart_poweroff_probe,
+1 -1
drivers/power/reset/vexpress-poweroff.c
··· 133 133 case FUNC_REBOOT: 134 134 ret = _vexpress_register_restart_handler(&pdev->dev); 135 135 break; 136 - }; 136 + } 137 137 138 138 return ret; 139 139 }
+2 -2
drivers/power/supply/88pm860x_battery.c
··· 109 109 }; 110 110 111 111 struct ccnt { 112 - unsigned long long int pos; 113 - unsigned long long int neg; 112 + unsigned long long pos; 113 + unsigned long long neg; 114 114 unsigned int spos; 115 115 unsigned int sneg; 116 116
+36 -4
drivers/power/supply/Kconfig
··· 698 698 699 699 config AB8500_BM 700 700 bool "AB8500 Battery Management Driver" 701 - depends on AB8500_CORE && AB8500_GPADC && (IIO = y) 701 + depends on AB8500_CORE && AB8500_GPADC && (IIO = y) && OF 702 702 help 703 703 Say Y to include support for AB8500 battery management. 704 704 705 705 config BATTERY_GOLDFISH 706 706 tristate "Goldfish battery driver" 707 - depends on GOLDFISH || COMPILE_TEST 708 707 depends on HAS_IOMEM 709 708 help 710 - Say Y to enable support for the battery and AC power in the 711 - Goldfish emulator. 709 + Say Y to enable support for the Goldfish battery and AC power 710 + driver. Originated in the Android Studio Emulator (goldfish) it is 711 + going to be used in other emulators. 712 712 713 713 config BATTERY_RT5033 714 714 tristate "RT5033 fuel gauge support" ··· 800 800 depends on MFD_ACER_A500_EC 801 801 help 802 802 Say Y to include support for Acer Iconia Tab A500 battery fuel gauge. 803 + 804 + config BATTERY_SURFACE 805 + tristate "Battery driver for 7th-generation Microsoft Surface devices" 806 + depends on SURFACE_AGGREGATOR_REGISTRY 807 + help 808 + Driver for battery devices connected via/managed by the Surface System 809 + Aggregator Module (SSAM). 810 + 811 + This driver provides battery-information and -status support for 812 + Surface devices where said data is not exposed via the standard ACPI 813 + devices. On those models (7th-generation), battery-information is 814 + instead handled directly via SSAM client devices and this driver. 815 + 816 + Say M or Y here to include battery status support for 7th-generation 817 + Microsoft Surface devices, i.e. Surface Pro 7, Surface Laptop 3, 818 + Surface Book 3, and Surface Laptop Go. 819 + 820 + config CHARGER_SURFACE 821 + tristate "AC driver for 7th-generation Microsoft Surface devices" 822 + depends on SURFACE_AGGREGATOR_REGISTRY 823 + help 824 + Driver for AC devices connected via/managed by the Surface System 825 + Aggregator Module (SSAM). 826 + 827 + This driver provides AC-information and -status support for Surface 828 + devices where said data is not exposed via the standard ACPI devices. 829 + On those models (7th-generation), AC-information is instead handled 830 + directly via a SSAM client device and this driver. 831 + 832 + Say M or Y here to include AC status support for 7th-generation 833 + Microsoft Surface devices, i.e. Surface Pro 7, Surface Laptop 3, 834 + Surface Book 3, and Surface Laptop Go. 803 835 804 836 endif # POWER_SUPPLY
+2
drivers/power/supply/Makefile
··· 101 101 obj-$(CONFIG_CHARGER_WILCO) += wilco-charger.o 102 102 obj-$(CONFIG_RN5T618_POWER) += rn5t618_power.o 103 103 obj-$(CONFIG_BATTERY_ACER_A500) += acer_a500_battery.o 104 + obj-$(CONFIG_BATTERY_SURFACE) += surface_battery.o 105 + obj-$(CONFIG_CHARGER_SURFACE) += surface_charger.o
+733
drivers/power/supply/ab8500-bm.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + 3 + #ifndef _AB8500_CHARGER_H_ 4 + #define _AB8500_CHARGER_H_ 5 + 6 + #include <linux/kernel.h> 7 + 8 + /* 9 + * System control 2 register offsets. 10 + * bank = 0x02 11 + */ 12 + #define AB8500_MAIN_WDOG_CTRL_REG 0x01 13 + #define AB8500_LOW_BAT_REG 0x03 14 + #define AB8500_BATT_OK_REG 0x04 15 + /* 16 + * USB/ULPI register offsets 17 + * Bank : 0x5 18 + */ 19 + #define AB8500_USB_LINE_STAT_REG 0x80 20 + #define AB8500_USB_LINE_CTRL2_REG 0x82 21 + #define AB8500_USB_LINK1_STAT_REG 0x94 22 + 23 + /* 24 + * Charger / status register offfsets 25 + * Bank : 0x0B 26 + */ 27 + #define AB8500_CH_STATUS1_REG 0x00 28 + #define AB8500_CH_STATUS2_REG 0x01 29 + #define AB8500_CH_USBCH_STAT1_REG 0x02 30 + #define AB8500_CH_USBCH_STAT2_REG 0x03 31 + #define AB8540_CH_USBCH_STAT3_REG 0x04 32 + #define AB8500_CH_STAT_REG 0x05 33 + 34 + /* 35 + * Charger / control register offfsets 36 + * Bank : 0x0B 37 + */ 38 + #define AB8500_CH_VOLT_LVL_REG 0x40 39 + #define AB8500_CH_VOLT_LVL_MAX_REG 0x41 /*Only in Cut2.0*/ 40 + #define AB8500_CH_OPT_CRNTLVL_REG 0x42 41 + #define AB8500_CH_OPT_CRNTLVL_MAX_REG 0x43 /*Only in Cut2.0*/ 42 + #define AB8500_CH_WD_TIMER_REG 0x50 43 + #define AB8500_CHARG_WD_CTRL 0x51 44 + #define AB8500_BTEMP_HIGH_TH 0x52 45 + #define AB8500_LED_INDICATOR_PWM_CTRL 0x53 46 + #define AB8500_LED_INDICATOR_PWM_DUTY 0x54 47 + #define AB8500_BATT_OVV 0x55 48 + #define AB8500_CHARGER_CTRL 0x56 49 + #define AB8500_BAT_CTRL_CURRENT_SOURCE 0x60 /*Only in Cut2.0*/ 50 + 51 + /* 52 + * Charger / main control register offsets 53 + * Bank : 0x0B 54 + */ 55 + #define AB8500_MCH_CTRL1 0x80 56 + #define AB8500_MCH_CTRL2 0x81 57 + #define AB8500_MCH_IPT_CURLVL_REG 0x82 58 + #define AB8500_CH_WD_REG 0x83 59 + 60 + /* 61 + * Charger / USB control register offsets 62 + * Bank : 0x0B 63 + */ 64 + #define AB8500_USBCH_CTRL1_REG 0xC0 65 + #define AB8500_USBCH_CTRL2_REG 0xC1 66 + #define AB8500_USBCH_IPT_CRNTLVL_REG 0xC2 67 + #define AB8540_USB_PP_MODE_REG 0xC5 68 + #define AB8540_USB_PP_CHR_REG 0xC6 69 + 70 + /* 71 + * Gas Gauge register offsets 72 + * Bank : 0x0C 73 + */ 74 + #define AB8500_GASG_CC_CTRL_REG 0x00 75 + #define AB8500_GASG_CC_ACCU1_REG 0x01 76 + #define AB8500_GASG_CC_ACCU2_REG 0x02 77 + #define AB8500_GASG_CC_ACCU3_REG 0x03 78 + #define AB8500_GASG_CC_ACCU4_REG 0x04 79 + #define AB8500_GASG_CC_SMPL_CNTRL_REG 0x05 80 + #define AB8500_GASG_CC_SMPL_CNTRH_REG 0x06 81 + #define AB8500_GASG_CC_SMPL_CNVL_REG 0x07 82 + #define AB8500_GASG_CC_SMPL_CNVH_REG 0x08 83 + #define AB8500_GASG_CC_CNTR_AVGOFF_REG 0x09 84 + #define AB8500_GASG_CC_OFFSET_REG 0x0A 85 + #define AB8500_GASG_CC_NCOV_ACCU 0x10 86 + #define AB8500_GASG_CC_NCOV_ACCU_CTRL 0x11 87 + #define AB8500_GASG_CC_NCOV_ACCU_LOW 0x12 88 + #define AB8500_GASG_CC_NCOV_ACCU_MED 0x13 89 + #define AB8500_GASG_CC_NCOV_ACCU_HIGH 0x14 90 + 91 + /* 92 + * Interrupt register offsets 93 + * Bank : 0x0E 94 + */ 95 + #define AB8500_IT_SOURCE2_REG 0x01 96 + #define AB8500_IT_SOURCE21_REG 0x14 97 + 98 + /* 99 + * RTC register offsets 100 + * Bank: 0x0F 101 + */ 102 + #define AB8500_RTC_BACKUP_CHG_REG 0x0C 103 + #define AB8500_RTC_CC_CONF_REG 0x01 104 + #define AB8500_RTC_CTRL_REG 0x0B 105 + #define AB8500_RTC_CTRL1_REG 0x11 106 + 107 + /* 108 + * OTP register offsets 109 + * Bank : 0x15 110 + */ 111 + #define AB8500_OTP_CONF_15 0x0E 112 + 113 + /* GPADC constants from AB8500 spec, UM0836 */ 114 + #define ADC_RESOLUTION 1024 115 + #define ADC_CH_MAIN_MIN 0 116 + #define ADC_CH_MAIN_MAX 20030 117 + #define ADC_CH_VBUS_MIN 0 118 + #define ADC_CH_VBUS_MAX 20030 119 + #define ADC_CH_VBAT_MIN 2300 120 + #define ADC_CH_VBAT_MAX 4800 121 + #define ADC_CH_BKBAT_MIN 0 122 + #define ADC_CH_BKBAT_MAX 3200 123 + 124 + /* Main charge i/p current */ 125 + #define MAIN_CH_IP_CUR_0P9A 0x80 126 + #define MAIN_CH_IP_CUR_1P0A 0x90 127 + #define MAIN_CH_IP_CUR_1P1A 0xA0 128 + #define MAIN_CH_IP_CUR_1P2A 0xB0 129 + #define MAIN_CH_IP_CUR_1P3A 0xC0 130 + #define MAIN_CH_IP_CUR_1P4A 0xD0 131 + #define MAIN_CH_IP_CUR_1P5A 0xE0 132 + 133 + /* ChVoltLevel */ 134 + #define CH_VOL_LVL_3P5 0x00 135 + #define CH_VOL_LVL_4P0 0x14 136 + #define CH_VOL_LVL_4P05 0x16 137 + #define CH_VOL_LVL_4P1 0x1B 138 + #define CH_VOL_LVL_4P15 0x20 139 + #define CH_VOL_LVL_4P2 0x25 140 + #define CH_VOL_LVL_4P6 0x4D 141 + 142 + /* ChOutputCurrentLevel */ 143 + #define CH_OP_CUR_LVL_0P1 0x00 144 + #define CH_OP_CUR_LVL_0P2 0x01 145 + #define CH_OP_CUR_LVL_0P3 0x02 146 + #define CH_OP_CUR_LVL_0P4 0x03 147 + #define CH_OP_CUR_LVL_0P5 0x04 148 + #define CH_OP_CUR_LVL_0P6 0x05 149 + #define CH_OP_CUR_LVL_0P7 0x06 150 + #define CH_OP_CUR_LVL_0P8 0x07 151 + #define CH_OP_CUR_LVL_0P9 0x08 152 + #define CH_OP_CUR_LVL_1P4 0x0D 153 + #define CH_OP_CUR_LVL_1P5 0x0E 154 + #define CH_OP_CUR_LVL_1P6 0x0F 155 + #define CH_OP_CUR_LVL_2P 0x3F 156 + 157 + /* BTEMP High thermal limits */ 158 + #define BTEMP_HIGH_TH_57_0 0x00 159 + #define BTEMP_HIGH_TH_52 0x01 160 + #define BTEMP_HIGH_TH_57_1 0x02 161 + #define BTEMP_HIGH_TH_62 0x03 162 + 163 + /* current is mA */ 164 + #define USB_0P1A 100 165 + #define USB_0P2A 200 166 + #define USB_0P3A 300 167 + #define USB_0P4A 400 168 + #define USB_0P5A 500 169 + 170 + #define LOW_BAT_3P1V 0x20 171 + #define LOW_BAT_2P3V 0x00 172 + #define LOW_BAT_RESET 0x01 173 + #define LOW_BAT_ENABLE 0x01 174 + 175 + /* Backup battery constants */ 176 + #define BUP_ICH_SEL_50UA 0x00 177 + #define BUP_ICH_SEL_150UA 0x04 178 + #define BUP_ICH_SEL_300UA 0x08 179 + #define BUP_ICH_SEL_700UA 0x0C 180 + 181 + enum bup_vch_sel { 182 + BUP_VCH_SEL_2P5V, 183 + BUP_VCH_SEL_2P6V, 184 + BUP_VCH_SEL_2P8V, 185 + BUP_VCH_SEL_3P1V, 186 + /* 187 + * Note that the following 5 values 2.7v, 2.9v, 3.0v, 3.2v, 3.3v 188 + * are only available on ab8540. You can't choose these 5 189 + * voltage on ab8500/ab8505/ab9540. 190 + */ 191 + BUP_VCH_SEL_2P7V, 192 + BUP_VCH_SEL_2P9V, 193 + BUP_VCH_SEL_3P0V, 194 + BUP_VCH_SEL_3P2V, 195 + BUP_VCH_SEL_3P3V, 196 + }; 197 + 198 + #define BUP_VCH_RANGE 0x02 199 + #define VBUP33_VRTCN 0x01 200 + 201 + /* Battery OVV constants */ 202 + #define BATT_OVV_ENA 0x02 203 + #define BATT_OVV_TH_3P7 0x00 204 + #define BATT_OVV_TH_4P75 0x01 205 + 206 + /* A value to indicate over voltage */ 207 + #define BATT_OVV_VALUE 4750 208 + 209 + /* VBUS OVV constants */ 210 + #define VBUS_OVV_SELECT_MASK 0x78 211 + #define VBUS_OVV_SELECT_5P6V 0x00 212 + #define VBUS_OVV_SELECT_5P7V 0x08 213 + #define VBUS_OVV_SELECT_5P8V 0x10 214 + #define VBUS_OVV_SELECT_5P9V 0x18 215 + #define VBUS_OVV_SELECT_6P0V 0x20 216 + #define VBUS_OVV_SELECT_6P1V 0x28 217 + #define VBUS_OVV_SELECT_6P2V 0x30 218 + #define VBUS_OVV_SELECT_6P3V 0x38 219 + 220 + #define VBUS_AUTO_IN_CURR_LIM_ENA 0x04 221 + 222 + /* Fuel Gauge constants */ 223 + #define RESET_ACCU 0x02 224 + #define READ_REQ 0x01 225 + #define CC_DEEP_SLEEP_ENA 0x02 226 + #define CC_PWR_UP_ENA 0x01 227 + #define CC_SAMPLES_40 0x28 228 + #define RD_NCONV_ACCU_REQ 0x01 229 + #define CC_CALIB 0x08 230 + #define CC_INTAVGOFFSET_ENA 0x10 231 + #define CC_MUXOFFSET 0x80 232 + #define CC_INT_CAL_N_AVG_MASK 0x60 233 + #define CC_INT_CAL_SAMPLES_16 0x40 234 + #define CC_INT_CAL_SAMPLES_8 0x20 235 + #define CC_INT_CAL_SAMPLES_4 0x00 236 + 237 + /* RTC constants */ 238 + #define RTC_BUP_CH_ENA 0x10 239 + 240 + /* BatCtrl Current Source Constants */ 241 + #define BAT_CTRL_7U_ENA 0x01 242 + #define BAT_CTRL_20U_ENA 0x02 243 + #define BAT_CTRL_18U_ENA 0x01 244 + #define BAT_CTRL_16U_ENA 0x02 245 + #define BAT_CTRL_CMP_ENA 0x04 246 + #define FORCE_BAT_CTRL_CMP_HIGH 0x08 247 + #define BAT_CTRL_PULL_UP_ENA 0x10 248 + 249 + /* Battery type */ 250 + #define BATTERY_UNKNOWN 00 251 + 252 + /* Registers for pcut feature in ab8505 and ab9540 */ 253 + #define AB8505_RTC_PCUT_CTL_STATUS_REG 0x12 254 + #define AB8505_RTC_PCUT_TIME_REG 0x13 255 + #define AB8505_RTC_PCUT_MAX_TIME_REG 0x14 256 + #define AB8505_RTC_PCUT_FLAG_TIME_REG 0x15 257 + #define AB8505_RTC_PCUT_RESTART_REG 0x16 258 + #define AB8505_RTC_PCUT_DEBOUNCE_REG 0x17 259 + 260 + /* USB Power Path constants for ab8540 */ 261 + #define BUS_VSYS_VOL_SELECT_MASK 0x06 262 + #define BUS_VSYS_VOL_SELECT_3P6V 0x00 263 + #define BUS_VSYS_VOL_SELECT_3P325V 0x02 264 + #define BUS_VSYS_VOL_SELECT_3P9V 0x04 265 + #define BUS_VSYS_VOL_SELECT_4P3V 0x06 266 + #define BUS_POWER_PATH_MODE_ENA 0x01 267 + #define BUS_PP_PRECHG_CURRENT_MASK 0x0E 268 + #define BUS_POWER_PATH_PRECHG_ENA 0x01 269 + 270 + /* 271 + * ADC for the battery thermistor. 272 + * When using the ABx500_ADC_THERM_BATCTRL the battery ID resistor is combined 273 + * with a NTC resistor to both identify the battery and to measure its 274 + * temperature. Different phone manufactures uses different techniques to both 275 + * identify the battery and to read its temperature. 276 + */ 277 + enum abx500_adc_therm { 278 + ABx500_ADC_THERM_BATCTRL, 279 + ABx500_ADC_THERM_BATTEMP, 280 + }; 281 + 282 + /** 283 + * struct abx500_res_to_temp - defines one point in a temp to res curve. To 284 + * be used in battery packs that combines the identification resistor with a 285 + * NTC resistor. 286 + * @temp: battery pack temperature in Celsius 287 + * @resist: NTC resistor net total resistance 288 + */ 289 + struct abx500_res_to_temp { 290 + int temp; 291 + int resist; 292 + }; 293 + 294 + /** 295 + * struct abx500_v_to_cap - Table for translating voltage to capacity 296 + * @voltage: Voltage in mV 297 + * @capacity: Capacity in percent 298 + */ 299 + struct abx500_v_to_cap { 300 + int voltage; 301 + int capacity; 302 + }; 303 + 304 + /* Forward declaration */ 305 + struct abx500_fg; 306 + 307 + /** 308 + * struct abx500_fg_parameters - Fuel gauge algorithm parameters, in seconds 309 + * if not specified 310 + * @recovery_sleep_timer: Time between measurements while recovering 311 + * @recovery_total_time: Total recovery time 312 + * @init_timer: Measurement interval during startup 313 + * @init_discard_time: Time we discard voltage measurement at startup 314 + * @init_total_time: Total init time during startup 315 + * @high_curr_time: Time current has to be high to go to recovery 316 + * @accu_charging: FG accumulation time while charging 317 + * @accu_high_curr: FG accumulation time in high current mode 318 + * @high_curr_threshold: High current threshold, in mA 319 + * @lowbat_threshold: Low battery threshold, in mV 320 + * @overbat_threshold: Over battery threshold, in mV 321 + * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 322 + * Resolution in 50 mV step. 323 + * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 324 + * Resolution in 50 mV step. 325 + * @user_cap_limit Capacity reported from user must be within this 326 + * limit to be considered as sane, in percentage 327 + * points. 328 + * @maint_thres This is the threshold where we stop reporting 329 + * battery full while in maintenance, in per cent 330 + * @pcut_enable: Enable power cut feature in ab8505 331 + * @pcut_max_time: Max time threshold 332 + * @pcut_flag_time: Flagtime threshold 333 + * @pcut_max_restart: Max number of restarts 334 + * @pcut_debounce_time: Sets battery debounce time 335 + */ 336 + struct abx500_fg_parameters { 337 + int recovery_sleep_timer; 338 + int recovery_total_time; 339 + int init_timer; 340 + int init_discard_time; 341 + int init_total_time; 342 + int high_curr_time; 343 + int accu_charging; 344 + int accu_high_curr; 345 + int high_curr_threshold; 346 + int lowbat_threshold; 347 + int overbat_threshold; 348 + int battok_falling_th_sel0; 349 + int battok_raising_th_sel1; 350 + int user_cap_limit; 351 + int maint_thres; 352 + bool pcut_enable; 353 + u8 pcut_max_time; 354 + u8 pcut_flag_time; 355 + u8 pcut_max_restart; 356 + u8 pcut_debounce_time; 357 + }; 358 + 359 + /** 360 + * struct abx500_charger_maximization - struct used by the board config. 361 + * @use_maxi: Enable maximization for this battery type 362 + * @maxi_chg_curr: Maximum charger current allowed 363 + * @maxi_wait_cycles: cycles to wait before setting charger current 364 + * @charger_curr_step delta between two charger current settings (mA) 365 + */ 366 + struct abx500_maxim_parameters { 367 + bool ena_maxi; 368 + int chg_curr; 369 + int wait_cycles; 370 + int charger_curr_step; 371 + }; 372 + 373 + /** 374 + * struct abx500_battery_type - different batteries supported 375 + * @name: battery technology 376 + * @resis_high: battery upper resistance limit 377 + * @resis_low: battery lower resistance limit 378 + * @charge_full_design: Maximum battery capacity in mAh 379 + * @nominal_voltage: Nominal voltage of the battery in mV 380 + * @termination_vol: max voltage upto which battery can be charged 381 + * @termination_curr battery charging termination current in mA 382 + * @recharge_cap battery capacity limit that will trigger a new 383 + * full charging cycle in the case where maintenan- 384 + * -ce charging has been disabled 385 + * @normal_cur_lvl: charger current in normal state in mA 386 + * @normal_vol_lvl: charger voltage in normal state in mV 387 + * @maint_a_cur_lvl: charger current in maintenance A state in mA 388 + * @maint_a_vol_lvl: charger voltage in maintenance A state in mV 389 + * @maint_a_chg_timer_h: charge time in maintenance A state 390 + * @maint_b_cur_lvl: charger current in maintenance B state in mA 391 + * @maint_b_vol_lvl: charger voltage in maintenance B state in mV 392 + * @maint_b_chg_timer_h: charge time in maintenance B state 393 + * @low_high_cur_lvl: charger current in temp low/high state in mA 394 + * @low_high_vol_lvl: charger voltage in temp low/high state in mV' 395 + * @battery_resistance: battery inner resistance in mOhm. 396 + * @n_r_t_tbl_elements: number of elements in r_to_t_tbl 397 + * @r_to_t_tbl: table containing resistance to temp points 398 + * @n_v_cap_tbl_elements: number of elements in v_to_cap_tbl 399 + * @v_to_cap_tbl: Voltage to capacity (in %) table 400 + * @n_batres_tbl_elements number of elements in the batres_tbl 401 + * @batres_tbl battery internal resistance vs temperature table 402 + */ 403 + struct abx500_battery_type { 404 + int name; 405 + int resis_high; 406 + int resis_low; 407 + int charge_full_design; 408 + int nominal_voltage; 409 + int termination_vol; 410 + int termination_curr; 411 + int recharge_cap; 412 + int normal_cur_lvl; 413 + int normal_vol_lvl; 414 + int maint_a_cur_lvl; 415 + int maint_a_vol_lvl; 416 + int maint_a_chg_timer_h; 417 + int maint_b_cur_lvl; 418 + int maint_b_vol_lvl; 419 + int maint_b_chg_timer_h; 420 + int low_high_cur_lvl; 421 + int low_high_vol_lvl; 422 + int battery_resistance; 423 + int n_temp_tbl_elements; 424 + const struct abx500_res_to_temp *r_to_t_tbl; 425 + int n_v_cap_tbl_elements; 426 + const struct abx500_v_to_cap *v_to_cap_tbl; 427 + int n_batres_tbl_elements; 428 + const struct batres_vs_temp *batres_tbl; 429 + }; 430 + 431 + /** 432 + * struct abx500_bm_capacity_levels - abx500 capacity level data 433 + * @critical: critical capacity level in percent 434 + * @low: low capacity level in percent 435 + * @normal: normal capacity level in percent 436 + * @high: high capacity level in percent 437 + * @full: full capacity level in percent 438 + */ 439 + struct abx500_bm_capacity_levels { 440 + int critical; 441 + int low; 442 + int normal; 443 + int high; 444 + int full; 445 + }; 446 + 447 + /** 448 + * struct abx500_bm_charger_parameters - Charger specific parameters 449 + * @usb_volt_max: maximum allowed USB charger voltage in mV 450 + * @usb_curr_max: maximum allowed USB charger current in mA 451 + * @ac_volt_max: maximum allowed AC charger voltage in mV 452 + * @ac_curr_max: maximum allowed AC charger current in mA 453 + */ 454 + struct abx500_bm_charger_parameters { 455 + int usb_volt_max; 456 + int usb_curr_max; 457 + int ac_volt_max; 458 + int ac_curr_max; 459 + }; 460 + 461 + /** 462 + * struct abx500_bm_data - abx500 battery management data 463 + * @temp_under under this temp, charging is stopped 464 + * @temp_low between this temp and temp_under charging is reduced 465 + * @temp_high between this temp and temp_over charging is reduced 466 + * @temp_over over this temp, charging is stopped 467 + * @temp_now present battery temperature 468 + * @temp_interval_chg temperature measurement interval in s when charging 469 + * @temp_interval_nochg temperature measurement interval in s when not charging 470 + * @main_safety_tmr_h safety timer for main charger 471 + * @usb_safety_tmr_h safety timer for usb charger 472 + * @bkup_bat_v voltage which we charge the backup battery with 473 + * @bkup_bat_i current which we charge the backup battery with 474 + * @no_maintenance indicates that maintenance charging is disabled 475 + * @capacity_scaling indicates whether capacity scaling is to be used 476 + * @abx500_adc_therm placement of thermistor, batctrl or battemp adc 477 + * @chg_unknown_bat flag to enable charging of unknown batteries 478 + * @enable_overshoot flag to enable VBAT overshoot control 479 + * @auto_trig flag to enable auto adc trigger 480 + * @fg_res resistance of FG resistor in 0.1mOhm 481 + * @n_btypes number of elements in array bat_type 482 + * @batt_id index of the identified battery in array bat_type 483 + * @interval_charging charge alg cycle period time when charging (sec) 484 + * @interval_not_charging charge alg cycle period time when not charging (sec) 485 + * @temp_hysteresis temperature hysteresis 486 + * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) 487 + * @n_chg_out_curr number of elements in array chg_output_curr 488 + * @n_chg_in_curr number of elements in array chg_input_curr 489 + * @chg_output_curr charger output current level map 490 + * @chg_input_curr charger input current level map 491 + * @maxi maximization parameters 492 + * @cap_levels capacity in percent for the different capacity levels 493 + * @bat_type table of supported battery types 494 + * @chg_params charger parameters 495 + * @fg_params fuel gauge parameters 496 + */ 497 + struct abx500_bm_data { 498 + int temp_under; 499 + int temp_low; 500 + int temp_high; 501 + int temp_over; 502 + int temp_now; 503 + int temp_interval_chg; 504 + int temp_interval_nochg; 505 + int main_safety_tmr_h; 506 + int usb_safety_tmr_h; 507 + int bkup_bat_v; 508 + int bkup_bat_i; 509 + bool autopower_cfg; 510 + bool ac_enabled; 511 + bool usb_enabled; 512 + bool no_maintenance; 513 + bool capacity_scaling; 514 + bool chg_unknown_bat; 515 + bool enable_overshoot; 516 + bool auto_trig; 517 + enum abx500_adc_therm adc_therm; 518 + int fg_res; 519 + int n_btypes; 520 + int batt_id; 521 + int interval_charging; 522 + int interval_not_charging; 523 + int temp_hysteresis; 524 + int gnd_lift_resistance; 525 + int n_chg_out_curr; 526 + int n_chg_in_curr; 527 + int *chg_output_curr; 528 + int *chg_input_curr; 529 + const struct abx500_maxim_parameters *maxi; 530 + const struct abx500_bm_capacity_levels *cap_levels; 531 + struct abx500_battery_type *bat_type; 532 + const struct abx500_bm_charger_parameters *chg_params; 533 + const struct abx500_fg_parameters *fg_params; 534 + }; 535 + 536 + enum { 537 + NTC_EXTERNAL = 0, 538 + NTC_INTERNAL, 539 + }; 540 + 541 + /** 542 + * struct res_to_temp - defines one point in a temp to res curve. To 543 + * be used in battery packs that combines the identification resistor with a 544 + * NTC resistor. 545 + * @temp: battery pack temperature in Celsius 546 + * @resist: NTC resistor net total resistance 547 + */ 548 + struct res_to_temp { 549 + int temp; 550 + int resist; 551 + }; 552 + 553 + /** 554 + * struct batres_vs_temp - defines one point in a temp vs battery internal 555 + * resistance curve. 556 + * @temp: battery pack temperature in Celsius 557 + * @resist: battery internal reistance in mOhm 558 + */ 559 + struct batres_vs_temp { 560 + int temp; 561 + int resist; 562 + }; 563 + 564 + /* Forward declaration */ 565 + struct ab8500_fg; 566 + 567 + /** 568 + * struct ab8500_fg_parameters - Fuel gauge algorithm parameters, in seconds 569 + * if not specified 570 + * @recovery_sleep_timer: Time between measurements while recovering 571 + * @recovery_total_time: Total recovery time 572 + * @init_timer: Measurement interval during startup 573 + * @init_discard_time: Time we discard voltage measurement at startup 574 + * @init_total_time: Total init time during startup 575 + * @high_curr_time: Time current has to be high to go to recovery 576 + * @accu_charging: FG accumulation time while charging 577 + * @accu_high_curr: FG accumulation time in high current mode 578 + * @high_curr_threshold: High current threshold, in mA 579 + * @lowbat_threshold: Low battery threshold, in mV 580 + * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 581 + * Resolution in 50 mV step. 582 + * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 583 + * Resolution in 50 mV step. 584 + * @user_cap_limit Capacity reported from user must be within this 585 + * limit to be considered as sane, in percentage 586 + * points. 587 + * @maint_thres This is the threshold where we stop reporting 588 + * battery full while in maintenance, in per cent 589 + * @pcut_enable: Enable power cut feature in ab8505 590 + * @pcut_max_time: Max time threshold 591 + * @pcut_flag_time: Flagtime threshold 592 + * @pcut_max_restart: Max number of restarts 593 + * @pcut_debunce_time: Sets battery debounce time 594 + */ 595 + struct ab8500_fg_parameters { 596 + int recovery_sleep_timer; 597 + int recovery_total_time; 598 + int init_timer; 599 + int init_discard_time; 600 + int init_total_time; 601 + int high_curr_time; 602 + int accu_charging; 603 + int accu_high_curr; 604 + int high_curr_threshold; 605 + int lowbat_threshold; 606 + int battok_falling_th_sel0; 607 + int battok_raising_th_sel1; 608 + int user_cap_limit; 609 + int maint_thres; 610 + bool pcut_enable; 611 + u8 pcut_max_time; 612 + u8 pcut_flag_time; 613 + u8 pcut_max_restart; 614 + u8 pcut_debunce_time; 615 + }; 616 + 617 + /** 618 + * struct ab8500_charger_maximization - struct used by the board config. 619 + * @use_maxi: Enable maximization for this battery type 620 + * @maxi_chg_curr: Maximum charger current allowed 621 + * @maxi_wait_cycles: cycles to wait before setting charger current 622 + * @charger_curr_step delta between two charger current settings (mA) 623 + */ 624 + struct ab8500_maxim_parameters { 625 + bool ena_maxi; 626 + int chg_curr; 627 + int wait_cycles; 628 + int charger_curr_step; 629 + }; 630 + 631 + /** 632 + * struct ab8500_bm_capacity_levels - ab8500 capacity level data 633 + * @critical: critical capacity level in percent 634 + * @low: low capacity level in percent 635 + * @normal: normal capacity level in percent 636 + * @high: high capacity level in percent 637 + * @full: full capacity level in percent 638 + */ 639 + struct ab8500_bm_capacity_levels { 640 + int critical; 641 + int low; 642 + int normal; 643 + int high; 644 + int full; 645 + }; 646 + 647 + /** 648 + * struct ab8500_bm_charger_parameters - Charger specific parameters 649 + * @usb_volt_max: maximum allowed USB charger voltage in mV 650 + * @usb_curr_max: maximum allowed USB charger current in mA 651 + * @ac_volt_max: maximum allowed AC charger voltage in mV 652 + * @ac_curr_max: maximum allowed AC charger current in mA 653 + */ 654 + struct ab8500_bm_charger_parameters { 655 + int usb_volt_max; 656 + int usb_curr_max; 657 + int ac_volt_max; 658 + int ac_curr_max; 659 + }; 660 + 661 + /** 662 + * struct ab8500_bm_data - ab8500 battery management data 663 + * @temp_under under this temp, charging is stopped 664 + * @temp_low between this temp and temp_under charging is reduced 665 + * @temp_high between this temp and temp_over charging is reduced 666 + * @temp_over over this temp, charging is stopped 667 + * @temp_interval_chg temperature measurement interval in s when charging 668 + * @temp_interval_nochg temperature measurement interval in s when not charging 669 + * @main_safety_tmr_h safety timer for main charger 670 + * @usb_safety_tmr_h safety timer for usb charger 671 + * @bkup_bat_v voltage which we charge the backup battery with 672 + * @bkup_bat_i current which we charge the backup battery with 673 + * @no_maintenance indicates that maintenance charging is disabled 674 + * @capacity_scaling indicates whether capacity scaling is to be used 675 + * @adc_therm placement of thermistor, batctrl or battemp adc 676 + * @chg_unknown_bat flag to enable charging of unknown batteries 677 + * @enable_overshoot flag to enable VBAT overshoot control 678 + * @fg_res resistance of FG resistor in 0.1mOhm 679 + * @n_btypes number of elements in array bat_type 680 + * @batt_id index of the identified battery in array bat_type 681 + * @interval_charging charge alg cycle period time when charging (sec) 682 + * @interval_not_charging charge alg cycle period time when not charging (sec) 683 + * @temp_hysteresis temperature hysteresis 684 + * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) 685 + * @maxi: maximization parameters 686 + * @cap_levels capacity in percent for the different capacity levels 687 + * @bat_type table of supported battery types 688 + * @chg_params charger parameters 689 + * @fg_params fuel gauge parameters 690 + */ 691 + struct ab8500_bm_data { 692 + int temp_under; 693 + int temp_low; 694 + int temp_high; 695 + int temp_over; 696 + int temp_interval_chg; 697 + int temp_interval_nochg; 698 + int main_safety_tmr_h; 699 + int usb_safety_tmr_h; 700 + int bkup_bat_v; 701 + int bkup_bat_i; 702 + bool no_maintenance; 703 + bool capacity_scaling; 704 + bool chg_unknown_bat; 705 + bool enable_overshoot; 706 + enum abx500_adc_therm adc_therm; 707 + int fg_res; 708 + int n_btypes; 709 + int batt_id; 710 + int interval_charging; 711 + int interval_not_charging; 712 + int temp_hysteresis; 713 + int gnd_lift_resistance; 714 + const struct ab8500_maxim_parameters *maxi; 715 + const struct ab8500_bm_capacity_levels *cap_levels; 716 + const struct ab8500_bm_charger_parameters *chg_params; 717 + const struct ab8500_fg_parameters *fg_params; 718 + }; 719 + 720 + extern struct abx500_bm_data ab8500_bm_data; 721 + 722 + void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); 723 + struct ab8500_fg *ab8500_fg_get(void); 724 + int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev); 725 + int ab8500_fg_inst_curr_start(struct ab8500_fg *di); 726 + int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res); 727 + int ab8500_fg_inst_curr_started(struct ab8500_fg *di); 728 + int ab8500_fg_inst_curr_done(struct ab8500_fg *di); 729 + int ab8500_bm_of_probe(struct device *dev, 730 + struct device_node *np, 731 + struct abx500_bm_data *bm); 732 + 733 + #endif /* _AB8500_CHARGER_H_ */
+51
drivers/power/supply/ab8500-chargalg.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (C) ST-Ericsson SA 2012 4 + * Author: Johan Gardsmark <johan.gardsmark@stericsson.com> for ST-Ericsson. 5 + */ 6 + 7 + #ifndef _AB8500_CHARGALG_H_ 8 + #define _AB8500_CHARGALG_H_ 9 + 10 + #include <linux/power_supply.h> 11 + 12 + /* 13 + * Valid only for supplies of type: 14 + * - POWER_SUPPLY_TYPE_MAINS, 15 + * - POWER_SUPPLY_TYPE_USB, 16 + * because only them store as drv_data pointer to struct ux500_charger. 17 + */ 18 + #define psy_to_ux500_charger(x) power_supply_get_drvdata(psy) 19 + 20 + /* Forward declaration */ 21 + struct ux500_charger; 22 + 23 + struct ux500_charger_ops { 24 + int (*enable) (struct ux500_charger *, int, int, int); 25 + int (*check_enable) (struct ux500_charger *, int, int); 26 + int (*kick_wd) (struct ux500_charger *); 27 + int (*update_curr) (struct ux500_charger *, int); 28 + }; 29 + 30 + /** 31 + * struct ux500_charger - power supply ux500 charger sub class 32 + * @psy power supply base class 33 + * @ops ux500 charger operations 34 + * @max_out_volt maximum output charger voltage in mV 35 + * @max_out_curr maximum output charger current in mA 36 + * @enabled indicates if this charger is used or not 37 + * @external external charger unit (pm2xxx) 38 + */ 39 + struct ux500_charger { 40 + struct power_supply *psy; 41 + struct ux500_charger_ops ops; 42 + int max_out_volt; 43 + int max_out_curr; 44 + int wdt_refresh; 45 + bool enabled; 46 + bool external; 47 + }; 48 + 49 + extern struct blocking_notifier_head charger_notifier_list; 50 + 51 + #endif /* _AB8500_CHARGALG_H_ */
+2 -1
drivers/power/supply/ab8500_bmdata.c
··· 4 4 #include <linux/of.h> 5 5 #include <linux/mfd/abx500.h> 6 6 #include <linux/mfd/abx500/ab8500.h> 7 - #include <linux/mfd/abx500/ab8500-bm.h> 7 + 8 + #include "ab8500-bm.h" 8 9 9 10 /* 10 11 * These are the defined batteries that uses a NTC and ID resistor placed
+8 -37
drivers/power/supply/ab8500_btemp.c
··· 25 25 #include <linux/mfd/core.h> 26 26 #include <linux/mfd/abx500.h> 27 27 #include <linux/mfd/abx500/ab8500.h> 28 - #include <linux/mfd/abx500/ab8500-bm.h> 29 28 #include <linux/iio/consumer.h> 29 + 30 + #include "ab8500-bm.h" 30 31 31 32 #define VTVOUT_V 1800 32 33 ··· 119 118 }; 120 119 121 120 static LIST_HEAD(ab8500_btemp_list); 122 - 123 - /** 124 - * ab8500_btemp_get() - returns a reference to the primary AB8500 BTEMP 125 - * (i.e. the first BTEMP in the instance list) 126 - */ 127 - struct ab8500_btemp *ab8500_btemp_get(void) 128 - { 129 - return list_first_entry(&ab8500_btemp_list, struct ab8500_btemp, node); 130 - } 131 - EXPORT_SYMBOL(ab8500_btemp_get); 132 121 133 122 /** 134 123 * ab8500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance ··· 745 754 * 746 755 * Returns battery temperature 747 756 */ 748 - int ab8500_btemp_get_temp(struct ab8500_btemp *di) 757 + static int ab8500_btemp_get_temp(struct ab8500_btemp *di) 749 758 { 750 759 int temp = 0; 751 760 ··· 781 790 } 782 791 return temp; 783 792 } 784 - EXPORT_SYMBOL(ab8500_btemp_get_temp); 785 - 786 - /** 787 - * ab8500_btemp_get_batctrl_temp() - get the temperature 788 - * @btemp: pointer to the btemp structure 789 - * 790 - * Returns the batctrl temperature in millidegrees 791 - */ 792 - int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp) 793 - { 794 - return btemp->bat_temp * 1000; 795 - } 796 - EXPORT_SYMBOL(ab8500_btemp_get_batctrl_temp); 797 793 798 794 /** 799 795 * ab8500_btemp_get_property() - get the btemp properties ··· 969 991 static int ab8500_btemp_probe(struct platform_device *pdev) 970 992 { 971 993 struct device_node *np = pdev->dev.of_node; 972 - struct abx500_bm_data *plat = pdev->dev.platform_data; 973 994 struct power_supply_config psy_cfg = {}; 974 995 struct device *dev = &pdev->dev; 975 996 struct ab8500_btemp *di; ··· 979 1002 if (!di) 980 1003 return -ENOMEM; 981 1004 982 - if (!plat) { 983 - dev_err(dev, "no battery management data supplied\n"); 984 - return -EINVAL; 985 - } 986 - di->bm = plat; 1005 + di->bm = &ab8500_bm_data; 987 1006 988 - if (np) { 989 - ret = ab8500_bm_of_probe(dev, np, di->bm); 990 - if (ret) { 991 - dev_err(dev, "failed to get battery information\n"); 992 - return ret; 993 - } 1007 + ret = ab8500_bm_of_probe(dev, np, di->bm); 1008 + if (ret) { 1009 + dev_err(dev, "failed to get battery information\n"); 1010 + return ret; 994 1011 } 995 1012 996 1013 /* get parent data */
+10 -17
drivers/power/supply/ab8500_charger.c
··· 28 28 #include <linux/mfd/core.h> 29 29 #include <linux/mfd/abx500/ab8500.h> 30 30 #include <linux/mfd/abx500.h> 31 - #include <linux/mfd/abx500/ab8500-bm.h> 32 - #include <linux/mfd/abx500/ux500_chargalg.h> 33 31 #include <linux/usb/otg.h> 34 32 #include <linux/mutex.h> 35 33 #include <linux/iio/consumer.h> 34 + 35 + #include "ab8500-bm.h" 36 + #include "ab8500-chargalg.h" 36 37 37 38 /* Charger constants */ 38 39 #define NO_PW_CONN 0 ··· 3345 3344 static int ab8500_charger_probe(struct platform_device *pdev) 3346 3345 { 3347 3346 struct device_node *np = pdev->dev.of_node; 3348 - struct abx500_bm_data *plat = pdev->dev.platform_data; 3349 3347 struct power_supply_config ac_psy_cfg = {}, usb_psy_cfg = {}; 3350 3348 struct ab8500_charger *di; 3351 3349 int irq, i, charger_status, ret = 0, ch_stat; ··· 3354 3354 if (!di) 3355 3355 return -ENOMEM; 3356 3356 3357 - if (!plat) { 3358 - dev_err(dev, "no battery management data supplied\n"); 3359 - return -EINVAL; 3360 - } 3361 - di->bm = plat; 3357 + di->bm = &ab8500_bm_data; 3362 3358 3363 - if (np) { 3364 - ret = ab8500_bm_of_probe(dev, np, di->bm); 3365 - if (ret) { 3366 - dev_err(dev, "failed to get battery information\n"); 3367 - return ret; 3368 - } 3369 - di->autopower_cfg = of_property_read_bool(np, "autopower_cfg"); 3370 - } else 3371 - di->autopower_cfg = false; 3359 + ret = ab8500_bm_of_probe(dev, np, di->bm); 3360 + if (ret) { 3361 + dev_err(dev, "failed to get battery information\n"); 3362 + return ret; 3363 + } 3364 + di->autopower_cfg = of_property_read_bool(np, "autopower_cfg"); 3372 3365 3373 3366 /* get parent data */ 3374 3367 di->dev = dev;
+7 -13
drivers/power/supply/ab8500_fg.c
··· 31 31 #include <linux/mfd/core.h> 32 32 #include <linux/mfd/abx500.h> 33 33 #include <linux/mfd/abx500/ab8500.h> 34 - #include <linux/mfd/abx500/ab8500-bm.h> 35 34 #include <linux/iio/consumer.h> 36 35 #include <linux/kernel.h> 36 + 37 + #include "ab8500-bm.h" 37 38 38 39 #define MILLI_TO_MICRO 1000 39 40 #define FG_LSB_IN_MA 1627 ··· 3027 3026 static int ab8500_fg_probe(struct platform_device *pdev) 3028 3027 { 3029 3028 struct device_node *np = pdev->dev.of_node; 3030 - struct abx500_bm_data *plat = pdev->dev.platform_data; 3031 3029 struct power_supply_config psy_cfg = {}; 3032 3030 struct device *dev = &pdev->dev; 3033 3031 struct ab8500_fg *di; ··· 3037 3037 if (!di) 3038 3038 return -ENOMEM; 3039 3039 3040 - if (!plat) { 3041 - dev_err(dev, "no battery management data supplied\n"); 3042 - return -EINVAL; 3043 - } 3044 - di->bm = plat; 3040 + di->bm = &ab8500_bm_data; 3045 3041 3046 - if (np) { 3047 - ret = ab8500_bm_of_probe(dev, np, di->bm); 3048 - if (ret) { 3049 - dev_err(dev, "failed to get battery information\n"); 3050 - return ret; 3051 - } 3042 + ret = ab8500_bm_of_probe(dev, np, di->bm); 3043 + if (ret) { 3044 + dev_err(dev, "failed to get battery information\n"); 3045 + return ret; 3052 3046 } 3053 3047 3054 3048 mutex_init(&di->cc_lock);
+8 -14
drivers/power/supply/abx500_chargalg.c
··· 28 28 #include <linux/mfd/core.h> 29 29 #include <linux/mfd/abx500.h> 30 30 #include <linux/mfd/abx500/ab8500.h> 31 - #include <linux/mfd/abx500/ux500_chargalg.h> 32 - #include <linux/mfd/abx500/ab8500-bm.h> 33 31 #include <linux/notifier.h> 32 + 33 + #include "ab8500-bm.h" 34 + #include "ab8500-chargalg.h" 34 35 35 36 /* Watchdog kick interval */ 36 37 #define CHG_WD_INTERVAL (6 * HZ) ··· 1981 1980 static int abx500_chargalg_probe(struct platform_device *pdev) 1982 1981 { 1983 1982 struct device_node *np = pdev->dev.of_node; 1984 - struct abx500_bm_data *plat = pdev->dev.platform_data; 1985 1983 struct power_supply_config psy_cfg = {}; 1986 1984 struct abx500_chargalg *di; 1987 1985 int ret = 0; ··· 1991 1991 return -ENOMEM; 1992 1992 } 1993 1993 1994 - if (!plat) { 1995 - dev_err(&pdev->dev, "no battery management data supplied\n"); 1996 - return -EINVAL; 1997 - } 1998 - di->bm = plat; 1994 + di->bm = &ab8500_bm_data; 1999 1995 2000 - if (np) { 2001 - ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); 2002 - if (ret) { 2003 - dev_err(&pdev->dev, "failed to get battery information\n"); 2004 - return ret; 2005 - } 1996 + ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); 1997 + if (ret) { 1998 + dev_err(&pdev->dev, "failed to get battery information\n"); 1999 + return ret; 2006 2000 } 2007 2001 2008 2002 /* get device struct and parent */
+1 -1
drivers/power/supply/act8945a_charger.c
··· 18 18 static const char *act8945a_charger_model = "ACT8945A"; 19 19 static const char *act8945a_charger_manufacturer = "Active-semi"; 20 20 21 - /** 21 + /* 22 22 * ACT8945A Charger Register Map 23 23 */ 24 24
+3 -1
drivers/power/supply/axp20x_usb_power.c
··· 619 619 620 620 if (power->axp20x_id == AXP813_ID) { 621 621 /* Enable USB Battery Charging specification detection */ 622 - regmap_update_bits(axp20x->regmap, AXP288_BC_GLOBAL, 622 + ret = regmap_update_bits(axp20x->regmap, AXP288_BC_GLOBAL, 623 623 AXP813_BC_EN, AXP813_BC_EN); 624 + if (ret) 625 + return ret; 624 626 } 625 627 626 628 psy_cfg.of_node = pdev->dev.of_node;
+2
drivers/power/supply/bq256xx_charger.c
··· 202 202 * @client: i2c client structure 203 203 * @regmap: register map structure 204 204 * @dev: device structure 205 + * @charger: power supply registered for the charger 206 + * @battery: power supply registered for the battery 205 207 * @lock: mutex lock structure 206 208 * 207 209 * @usb2_phy: usb_phy identifier
+12 -28
drivers/power/supply/bq25980_charger.c
··· 606 606 return 0; 607 607 } 608 608 609 - static int bq25980_set_battery_property(struct power_supply *psy, 610 - enum power_supply_property psp, 611 - const union power_supply_propval *val) 612 - { 613 - struct bq25980_device *bq = power_supply_get_drvdata(psy); 614 - int ret = 0; 615 - 616 - switch (psp) { 617 - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: 618 - ret = bq25980_set_const_charge_curr(bq, val->intval); 619 - if (ret) 620 - return ret; 621 - break; 622 - 623 - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: 624 - ret = bq25980_set_const_charge_volt(bq, val->intval); 625 - if (ret) 626 - return ret; 627 - break; 628 - 629 - default: 630 - return -EINVAL; 631 - } 632 - 633 - return ret; 634 - } 635 - 636 609 static int bq25980_get_battery_property(struct power_supply *psy, 637 610 enum power_supply_property psp, 638 611 union power_supply_propval *val) ··· 670 697 671 698 case POWER_SUPPLY_PROP_STATUS: 672 699 ret = bq25980_set_chg_en(bq, val->intval); 700 + if (ret) 701 + return ret; 702 + break; 703 + 704 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: 705 + ret = bq25980_set_const_charge_curr(bq, val->intval); 706 + if (ret) 707 + return ret; 708 + break; 709 + 710 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: 711 + ret = bq25980_set_const_charge_volt(bq, val->intval); 673 712 if (ret) 674 713 return ret; 675 714 break; ··· 907 922 .name = "bq25980-battery", 908 923 .type = POWER_SUPPLY_TYPE_BATTERY, 909 924 .get_property = bq25980_get_battery_property, 910 - .set_property = bq25980_set_battery_property, 911 925 .properties = bq25980_battery_props, 912 926 .num_properties = ARRAY_SIZE(bq25980_battery_props), 913 927 .property_is_writeable = bq25980_property_is_writeable,
+106 -61
drivers/power/supply/bq27xxx_battery.c
··· 39 39 * https://www.ti.com/product/bq27z561 40 40 * https://www.ti.com/product/bq28z610 41 41 * https://www.ti.com/product/bq34z100-g1 42 + * https://www.ti.com/product/bq78z100 42 43 */ 43 44 44 45 #include <linux/device.h> ··· 516 515 [BQ27XXX_REG_DCAP] = 0x3c, 517 516 [BQ27XXX_REG_AP] = 0x22, 518 517 BQ27XXX_DM_REG_ROWS, 518 + }, 519 + bq78z100_regs[BQ27XXX_REG_MAX] = { 520 + [BQ27XXX_REG_CTRL] = 0x00, 521 + [BQ27XXX_REG_TEMP] = 0x06, 522 + [BQ27XXX_REG_INT_TEMP] = 0x28, 523 + [BQ27XXX_REG_VOLT] = 0x08, 524 + [BQ27XXX_REG_AI] = 0x14, 525 + [BQ27XXX_REG_FLAGS] = 0x0a, 526 + [BQ27XXX_REG_TTE] = 0x16, 527 + [BQ27XXX_REG_TTF] = 0x18, 528 + [BQ27XXX_REG_TTES] = 0x1c, 529 + [BQ27XXX_REG_TTECP] = INVALID_REG_ADDR, 530 + [BQ27XXX_REG_NAC] = INVALID_REG_ADDR, 531 + [BQ27XXX_REG_RC] = 0x10, 532 + [BQ27XXX_REG_FCC] = 0x12, 533 + [BQ27XXX_REG_CYCT] = 0x2a, 534 + [BQ27XXX_REG_AE] = INVALID_REG_ADDR, 535 + [BQ27XXX_REG_SOC] = 0x2c, 536 + [BQ27XXX_REG_DCAP] = 0x3c, 537 + [BQ27XXX_REG_AP] = 0x22, 538 + BQ27XXX_DM_REG_ROWS, 519 539 }; 520 540 521 541 static enum power_supply_property bq27000_props[] = { ··· 835 813 POWER_SUPPLY_PROP_MANUFACTURER, 836 814 }; 837 815 816 + static enum power_supply_property bq78z100_props[] = { 817 + POWER_SUPPLY_PROP_STATUS, 818 + POWER_SUPPLY_PROP_PRESENT, 819 + POWER_SUPPLY_PROP_VOLTAGE_NOW, 820 + POWER_SUPPLY_PROP_CURRENT_NOW, 821 + POWER_SUPPLY_PROP_CAPACITY, 822 + POWER_SUPPLY_PROP_CAPACITY_LEVEL, 823 + POWER_SUPPLY_PROP_TEMP, 824 + POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW, 825 + POWER_SUPPLY_PROP_TIME_TO_FULL_NOW, 826 + POWER_SUPPLY_PROP_TECHNOLOGY, 827 + POWER_SUPPLY_PROP_CHARGE_FULL, 828 + POWER_SUPPLY_PROP_CHARGE_NOW, 829 + POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, 830 + POWER_SUPPLY_PROP_CYCLE_COUNT, 831 + POWER_SUPPLY_PROP_POWER_AVG, 832 + POWER_SUPPLY_PROP_HEALTH, 833 + POWER_SUPPLY_PROP_MANUFACTURER, 834 + }; 835 + 838 836 struct bq27xxx_dm_reg { 839 837 u8 subclass_id; 840 838 u8 offset; ··· 953 911 #define bq27z561_dm_regs 0 954 912 #define bq28z610_dm_regs 0 955 913 #define bq34z100_dm_regs 0 914 + #define bq78z100_dm_regs 0 956 915 957 916 #define BQ27XXX_O_ZERO BIT(0) 958 917 #define BQ27XXX_O_OTDC BIT(1) /* has OTC/OTD overtemperature flags */ ··· 1012 969 [BQ28Z610] = BQ27XXX_DATA(bq28z610, 0 , BQ27Z561_O_BITS), 1013 970 [BQ34Z100] = BQ27XXX_DATA(bq34z100, 0 , BQ27XXX_O_OTDC | BQ27XXX_O_SOC_SI | \ 1014 971 BQ27XXX_O_HAS_CI | BQ27XXX_O_MUL_CHEM), 972 + [BQ78Z100] = BQ27XXX_DATA(bq78z100, 0 , BQ27Z561_O_BITS), 1015 973 }; 1016 974 1017 975 static DEFINE_MUTEX(bq27xxx_list_lock); ··· 1706 1662 } 1707 1663 1708 1664 /* 1709 - * Read an average power register. 1710 - * Return < 0 if something fails. 1711 - */ 1712 - static int bq27xxx_battery_read_pwr_avg(struct bq27xxx_device_info *di) 1713 - { 1714 - int tval; 1715 - 1716 - tval = bq27xxx_read(di, BQ27XXX_REG_AP, false); 1717 - if (tval < 0) { 1718 - dev_err(di->dev, "error reading average power register %02x: %d\n", 1719 - BQ27XXX_REG_AP, tval); 1720 - return tval; 1721 - } 1722 - 1723 - if (di->opts & BQ27XXX_O_ZERO) 1724 - return (tval * BQ27XXX_POWER_CONSTANT) / BQ27XXX_RS; 1725 - else 1726 - return tval; 1727 - } 1728 - 1729 - /* 1730 1665 * Returns true if a battery over temperature condition is detected 1731 1666 */ 1732 1667 static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags) ··· 1792 1769 } 1793 1770 if (di->regs[BQ27XXX_REG_CYCT] != INVALID_REG_ADDR) 1794 1771 cache.cycle_count = bq27xxx_battery_read_cyct(di); 1795 - if (di->regs[BQ27XXX_REG_AP] != INVALID_REG_ADDR) 1796 - cache.power_avg = bq27xxx_battery_read_pwr_avg(di); 1797 1772 1798 1773 /* We only have to read charge design full once */ 1799 1774 if (di->charge_design_full <= 0) ··· 1821 1800 schedule_delayed_work(&di->work, poll_interval * HZ); 1822 1801 } 1823 1802 1803 + static bool bq27xxx_battery_is_full(struct bq27xxx_device_info *di, int flags) 1804 + { 1805 + if (di->opts & BQ27XXX_O_ZERO) 1806 + return (flags & BQ27000_FLAG_FC); 1807 + else if (di->opts & BQ27Z561_O_BITS) 1808 + return (flags & BQ27Z561_FLAG_FC); 1809 + else 1810 + return (flags & BQ27XXX_FLAG_FC); 1811 + } 1812 + 1824 1813 /* 1825 - * Return the battery average current in µA 1814 + * Return the battery average current in µA and the status 1826 1815 * Note that current can be negative signed as well 1827 1816 * Or 0 if something fails. 1828 1817 */ 1829 - static int bq27xxx_battery_current(struct bq27xxx_device_info *di, 1830 - union power_supply_propval *val) 1818 + static int bq27xxx_battery_current_and_status( 1819 + struct bq27xxx_device_info *di, 1820 + union power_supply_propval *val_curr, 1821 + union power_supply_propval *val_status) 1831 1822 { 1823 + bool single_flags = (di->opts & BQ27XXX_O_ZERO); 1832 1824 int curr; 1833 1825 int flags; 1834 1826 ··· 1851 1817 return curr; 1852 1818 } 1853 1819 1820 + flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, single_flags); 1821 + if (flags < 0) { 1822 + dev_err(di->dev, "error reading flags\n"); 1823 + return flags; 1824 + } 1825 + 1854 1826 if (di->opts & BQ27XXX_O_ZERO) { 1855 - flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, true); 1856 1827 if (!(flags & BQ27000_FLAG_CHGS)) { 1857 1828 dev_dbg(di->dev, "negative current!\n"); 1858 1829 curr = -curr; 1859 1830 } 1860 1831 1861 - val->intval = curr * BQ27XXX_CURRENT_CONSTANT / BQ27XXX_RS; 1832 + curr = curr * BQ27XXX_CURRENT_CONSTANT / BQ27XXX_RS; 1862 1833 } else { 1863 1834 /* Other gauges return signed value */ 1864 - val->intval = -(int)((s16)curr) * 1000; 1835 + curr = (int)((s16)curr) * 1000; 1836 + } 1837 + 1838 + if (val_curr) 1839 + val_curr->intval = curr; 1840 + 1841 + if (val_status) { 1842 + if (curr > 0) { 1843 + val_status->intval = POWER_SUPPLY_STATUS_CHARGING; 1844 + } else if (curr < 0) { 1845 + val_status->intval = POWER_SUPPLY_STATUS_DISCHARGING; 1846 + } else { 1847 + if (bq27xxx_battery_is_full(di, flags)) 1848 + val_status->intval = POWER_SUPPLY_STATUS_FULL; 1849 + else 1850 + val_status->intval = 1851 + POWER_SUPPLY_STATUS_NOT_CHARGING; 1852 + } 1865 1853 } 1866 1854 1867 1855 return 0; 1868 1856 } 1869 1857 1870 - static int bq27xxx_battery_status(struct bq27xxx_device_info *di, 1871 - union power_supply_propval *val) 1858 + /* 1859 + * Get the average power in µW 1860 + * Return < 0 if something fails. 1861 + */ 1862 + static int bq27xxx_battery_pwr_avg(struct bq27xxx_device_info *di, 1863 + union power_supply_propval *val) 1872 1864 { 1873 - int status; 1865 + int power; 1874 1866 1875 - if (di->opts & BQ27XXX_O_ZERO) { 1876 - if (di->cache.flags & BQ27000_FLAG_FC) 1877 - status = POWER_SUPPLY_STATUS_FULL; 1878 - else if (di->cache.flags & BQ27000_FLAG_CHGS) 1879 - status = POWER_SUPPLY_STATUS_CHARGING; 1880 - else 1881 - status = POWER_SUPPLY_STATUS_DISCHARGING; 1882 - } else if (di->opts & BQ27Z561_O_BITS) { 1883 - if (di->cache.flags & BQ27Z561_FLAG_FC) 1884 - status = POWER_SUPPLY_STATUS_FULL; 1885 - else if (di->cache.flags & BQ27Z561_FLAG_DIS_CH) 1886 - status = POWER_SUPPLY_STATUS_DISCHARGING; 1887 - else 1888 - status = POWER_SUPPLY_STATUS_CHARGING; 1889 - } else { 1890 - if (di->cache.flags & BQ27XXX_FLAG_FC) 1891 - status = POWER_SUPPLY_STATUS_FULL; 1892 - else if (di->cache.flags & BQ27XXX_FLAG_DSC) 1893 - status = POWER_SUPPLY_STATUS_DISCHARGING; 1894 - else 1895 - status = POWER_SUPPLY_STATUS_CHARGING; 1867 + power = bq27xxx_read(di, BQ27XXX_REG_AP, false); 1868 + if (power < 0) { 1869 + dev_err(di->dev, 1870 + "error reading average power register %02x: %d\n", 1871 + BQ27XXX_REG_AP, power); 1872 + return power; 1896 1873 } 1897 1874 1898 - if ((status == POWER_SUPPLY_STATUS_DISCHARGING) && 1899 - (power_supply_am_i_supplied(di->bat) > 0)) 1900 - status = POWER_SUPPLY_STATUS_NOT_CHARGING; 1901 - 1902 - val->intval = status; 1875 + if (di->opts & BQ27XXX_O_ZERO) 1876 + val->intval = (power * BQ27XXX_POWER_CONSTANT) / BQ27XXX_RS; 1877 + else 1878 + /* Other gauges return a signed value in units of 10mW */ 1879 + val->intval = (int)((s16)power) * 10000; 1903 1880 1904 1881 return 0; 1905 1882 } ··· 2002 1957 2003 1958 switch (psp) { 2004 1959 case POWER_SUPPLY_PROP_STATUS: 2005 - ret = bq27xxx_battery_status(di, val); 1960 + ret = bq27xxx_battery_current_and_status(di, NULL, val); 2006 1961 break; 2007 1962 case POWER_SUPPLY_PROP_VOLTAGE_NOW: 2008 1963 ret = bq27xxx_battery_voltage(di, val); ··· 2011 1966 val->intval = di->cache.flags < 0 ? 0 : 1; 2012 1967 break; 2013 1968 case POWER_SUPPLY_PROP_CURRENT_NOW: 2014 - ret = bq27xxx_battery_current(di, val); 1969 + ret = bq27xxx_battery_current_and_status(di, val, NULL); 2015 1970 break; 2016 1971 case POWER_SUPPLY_PROP_CAPACITY: 2017 1972 ret = bq27xxx_simple_value(di->cache.capacity, val); ··· 2065 2020 ret = bq27xxx_simple_value(di->cache.energy, val); 2066 2021 break; 2067 2022 case POWER_SUPPLY_PROP_POWER_AVG: 2068 - ret = bq27xxx_simple_value(di->cache.power_avg, val); 2023 + ret = bq27xxx_battery_pwr_avg(di, val); 2069 2024 break; 2070 2025 case POWER_SUPPLY_PROP_HEALTH: 2071 2026 ret = bq27xxx_simple_value(di->cache.health, val);
+2
drivers/power/supply/bq27xxx_battery_i2c.c
··· 248 248 { "bq27z561", BQ27Z561 }, 249 249 { "bq28z610", BQ28Z610 }, 250 250 { "bq34z100", BQ34Z100 }, 251 + { "bq78z100", BQ78Z100 }, 251 252 {}, 252 253 }; 253 254 MODULE_DEVICE_TABLE(i2c, bq27xxx_i2c_id_table); ··· 285 284 { .compatible = "ti,bq27z561" }, 286 285 { .compatible = "ti,bq28z610" }, 287 286 { .compatible = "ti,bq34z100" }, 287 + { .compatible = "ti,bq78z100" }, 288 288 {}, 289 289 }; 290 290 MODULE_DEVICE_TABLE(of, bq27xxx_battery_i2c_of_match_table);
+1 -1
drivers/power/supply/charger-manager.c
··· 1604 1604 mutex_unlock(&cm_list_mtx); 1605 1605 1606 1606 /* 1607 - * Charger-manager is capable of waking up the systme from sleep 1607 + * Charger-manager is capable of waking up the system from sleep 1608 1608 * when event is happened through cm_notify_event() 1609 1609 */ 1610 1610 device_init_wakeup(&pdev->dev, true);
+1 -1
drivers/power/supply/cpcap-battery.c
··· 786 786 break; 787 787 } 788 788 789 - if (!d) 789 + if (list_entry_is_head(d, &ddata->irq_list, node)) 790 790 return IRQ_NONE; 791 791 792 792 latest = cpcap_battery_latest(ddata);
+5 -2
drivers/power/supply/cpcap-charger.c
··· 318 318 return CPCAP_REG_CRM_ICHRG(0x0); 319 319 if (miliamp < 177) 320 320 return CPCAP_REG_CRM_ICHRG(0x1); 321 - if (miliamp > 1596) 321 + if (miliamp >= 1596) 322 322 return CPCAP_REG_CRM_ICHRG(0xe); 323 323 324 324 res = microamp / 88666; ··· 465 465 466 466 error = iio_read_channel_processed(channel, &value); 467 467 if (error >= 0) 468 - return value > 3900 ? true : false; 468 + return value > 3900; 469 469 470 470 dev_err(ddata->dev, "error reading VBUS: %i\n", error); 471 471 ··· 667 667 668 668 return; 669 669 } 670 + 671 + /* Delay for 80ms to avoid vbus bouncing when usb cable is plugged in */ 672 + usleep_range(80000, 120000); 670 673 671 674 /* Throttle chrgcurr2 interrupt for charger done and retry */ 672 675 switch (ddata->status) {
+6
drivers/power/supply/cw2015_battery.c
··· 511 511 val->intval = 0; 512 512 break; 513 513 514 + case POWER_SUPPLY_PROP_CHARGE_NOW: 515 + val->intval = cw_bat->battery.charge_full_design_uah; 516 + val->intval = val->intval * cw_bat->soc / 100; 517 + break; 518 + 514 519 case POWER_SUPPLY_PROP_CURRENT_NOW: 515 520 if (cw_battery_valid_time_to_empty(cw_bat) && 516 521 cw_bat->battery.charge_full_design_uah > 0) { ··· 547 542 POWER_SUPPLY_PROP_CHARGE_COUNTER, 548 543 POWER_SUPPLY_PROP_CHARGE_FULL, 549 544 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, 545 + POWER_SUPPLY_PROP_CHARGE_NOW, 550 546 POWER_SUPPLY_PROP_CURRENT_NOW, 551 547 }; 552 548
+4 -4
drivers/power/supply/ds2781_battery.c
··· 626 626 struct bin_attribute *bin_attr, 627 627 char *buf, loff_t off, size_t count) 628 628 { 629 - struct device *dev = container_of(kobj, struct device, kobj); 629 + struct device *dev = kobj_to_dev(kobj); 630 630 struct power_supply *psy = to_power_supply(dev); 631 631 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); 632 632 ··· 639 639 struct bin_attribute *bin_attr, 640 640 char *buf, loff_t off, size_t count) 641 641 { 642 - struct device *dev = container_of(kobj, struct device, kobj); 642 + struct device *dev = kobj_to_dev(kobj); 643 643 struct power_supply *psy = to_power_supply(dev); 644 644 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); 645 645 int ret; ··· 671 671 struct bin_attribute *bin_attr, 672 672 char *buf, loff_t off, size_t count) 673 673 { 674 - struct device *dev = container_of(kobj, struct device, kobj); 674 + struct device *dev = kobj_to_dev(kobj); 675 675 struct power_supply *psy = to_power_supply(dev); 676 676 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); 677 677 ··· 685 685 struct bin_attribute *bin_attr, 686 686 char *buf, loff_t off, size_t count) 687 687 { 688 - struct device *dev = container_of(kobj, struct device, kobj); 688 + struct device *dev = kobj_to_dev(kobj); 689 689 struct power_supply *psy = to_power_supply(dev); 690 690 struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); 691 691 int ret;
+1 -1
drivers/power/supply/generic-adc-battery.c
··· 373 373 } 374 374 375 375 kfree(adc_bat->psy_desc.properties); 376 - cancel_delayed_work(&adc_bat->bat_work); 376 + cancel_delayed_work_sync(&adc_bat->bat_work); 377 377 return 0; 378 378 } 379 379
+1 -1
drivers/power/supply/lp8788-charger.c
··· 501 501 502 502 ret = request_threaded_irq(virq, NULL, 503 503 lp8788_charger_irq_thread, 504 - 0, name, pchg); 504 + IRQF_ONESHOT, name, pchg); 505 505 if (ret) 506 506 break; 507 507 }
+1 -1
drivers/power/supply/max14577_charger.c
··· 261 261 static int max14577_init_eoc(struct max14577_charger *chg, 262 262 unsigned int uamp) 263 263 { 264 - unsigned int current_bits = 0xf; 264 + unsigned int current_bits; 265 265 u8 reg_data; 266 266 267 267 switch (chg->max14577->dev_type) {
+5 -7
drivers/power/supply/max17040_battery.c
··· 268 268 rcomp_len = device_property_count_u8(dev, "maxim,rcomp"); 269 269 chip->rcomp = MAX17040_RCOMP_DEFAULT; 270 270 if (rcomp_len == data->rcomp_bytes) { 271 - device_property_read_u8_array(dev, "maxim,rcomp", 272 - rcomp, rcomp_len); 273 - chip->rcomp = rcomp_len == 2 ? 274 - rcomp[0] << 8 | rcomp[1] : 275 - rcomp[0] << 8; 271 + if (!device_property_read_u8_array(dev, "maxim,rcomp", 272 + rcomp, rcomp_len)) 273 + chip->rcomp = rcomp_len == 2 ? rcomp[0] << 8 | rcomp[1] : 274 + rcomp[0] << 8; 276 275 } else if (rcomp_len > 0) { 277 276 dev_err(dev, "maxim,rcomp has incorrect length\n"); 278 277 return -EINVAL; ··· 486 487 ret = max17040_get_of_data(chip); 487 488 if (ret) 488 489 return ret; 489 - chip_id = (enum chip_id) (uintptr_t) 490 - of_device_get_match_data(&client->dev); 490 + chip_id = (uintptr_t)of_device_get_match_data(&client->dev); 491 491 } 492 492 chip->data = max17040_family[chip_id]; 493 493
+4 -4
drivers/power/supply/max17042_battery.c
··· 131 131 * 132 132 * When this cycle the battery gets charged to a higher (calculated) 133 133 * capacity then the previous cycle then FullCAP will get updated 134 - * contineously once end-of-charge detection kicks in, so allow the 134 + * continuously once end-of-charge detection kicks in, so allow the 135 135 * 2 to differ a bit. 136 136 */ 137 137 ··· 739 739 740 740 /* 741 741 * Block write all the override values coming from platform data. 742 - * This function MUST be called before the POR initialization proceedure 742 + * This function MUST be called before the POR initialization procedure 743 743 * specified by maxim. 744 744 */ 745 745 static inline void max17042_override_por_values(struct max17042_chip *chip) ··· 811 811 */ 812 812 msleep(500); 813 813 814 - /* Initialize configaration */ 814 + /* Initialize configuration */ 815 815 max17042_write_config_regs(chip); 816 816 817 817 /* write cell characterization data */ ··· 855 855 struct regmap *map = chip->regmap; 856 856 u32 soc, soc_tr; 857 857 858 - /* program interrupt thesholds such that we should 858 + /* program interrupt thresholds such that we should 859 859 * get interrupt for every 'off' perc change in the soc 860 860 */ 861 861 regmap_read(map, MAX17042_RepSOC, &soc);
+7 -7
drivers/power/supply/max1721x_battery.c
··· 1 1 /* 2 2 * 1-Wire implementation for Maxim Semiconductor 3 - * MAX7211/MAX17215 stanalone fuel gauge chip 3 + * MAX7211/MAX17215 standalone fuel gauge chip 4 4 * 5 5 * Copyright (C) 2017 Radioavionica Corporation 6 6 * Author: Alex A. Mihaylov <minimumlaw@rambler.ru> ··· 28 28 /* Number of valid register addresses in W1 mode */ 29 29 #define MAX1721X_MAX_REG_NR 0x1EF 30 30 31 - /* Factory settings (nonvilatile registers) (W1 specific) */ 31 + /* Factory settings (nonvolatile registers) (W1 specific) */ 32 32 #define MAX1721X_REG_NRSENSE 0x1CF /* RSense in 10^-5 Ohm */ 33 33 /* Strings */ 34 34 #define MAX1721X_REG_MFG_STR 0x1CC ··· 105 105 /* 106 106 * Calculating current registers resolution: 107 107 * 108 - * RSense stored in 10^-5 Ohm, so mesaurment voltage must be 108 + * RSense stored in 10^-5 Ohm, so measurement voltage must be 109 109 * in 10^-11 Volts for get current in uA. 110 110 * 16 bit current reg fullscale +/-51.2mV is 102400 uV. 111 111 * So: 102400 / 65535 * 10^5 = 156252 ··· 137 137 /* 138 138 * POWER_SUPPLY_PROP_PRESENT will always readable via 139 139 * sysfs interface. Value return 0 if battery not 140 - * present or unaccesable via W1. 140 + * present or unaccessible via W1. 141 141 */ 142 142 val->intval = 143 143 regmap_read(info->regmap, MAX172XX_REG_STATUS, ··· 334 334 335 335 /* 336 336 * power_supply class battery name translated from W1 slave device 337 - * unical ID (look like 26-0123456789AB) to "max1721x-0123456789AB\0" 338 - * so, 26 (device family) correcpondent to max1721x devices. 339 - * Device name still unical for any numbers connected devices. 337 + * unique ID (look like 26-0123456789AB) to "max1721x-0123456789AB\0" 338 + * so, 26 (device family) correspond to max1721x devices. 339 + * Device name still unique for any number of connected devices. 340 340 */ 341 341 snprintf(info->name, sizeof(info->name), 342 342 "max1721x-%012X", (unsigned int)sl->reg_num.id);
+9 -5
drivers/power/supply/max8997_charger.c
··· 168 168 int ret = 0; 169 169 struct charger_data *charger; 170 170 struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); 171 + struct device_node *np = pdev->dev.of_node; 171 172 struct i2c_client *i2c = iodev->i2c; 172 173 struct max8997_platform_data *pdata = iodev->pdata; 173 174 struct power_supply_config psy_cfg = {}; ··· 238 237 return PTR_ERR(charger->battery); 239 238 } 240 239 240 + // grab regulator from parent device's node 241 + pdev->dev.of_node = iodev->dev->of_node; 241 242 charger->reg = devm_regulator_get_optional(&pdev->dev, "charger"); 243 + pdev->dev.of_node = np; 242 244 if (IS_ERR(charger->reg)) { 243 245 if (PTR_ERR(charger->reg) == -EPROBE_DEFER) 244 246 return -EPROBE_DEFER; 245 247 dev_info(&pdev->dev, "couldn't get charger regulator\n"); 246 248 } 247 - charger->edev = extcon_get_edev_by_phandle(&pdev->dev, 0); 248 - if (IS_ERR(charger->edev)) { 249 - if (PTR_ERR(charger->edev) == -EPROBE_DEFER) 249 + charger->edev = extcon_get_extcon_dev("max8997-muic"); 250 + if (IS_ERR_OR_NULL(charger->edev)) { 251 + if (!charger->edev) 250 252 return -EPROBE_DEFER; 251 253 dev_info(charger->dev, "couldn't get extcon device\n"); 252 254 } 253 255 254 - if (!IS_ERR(charger->reg) && !IS_ERR(charger->edev)) { 256 + if (!IS_ERR(charger->reg) && !IS_ERR_OR_NULL(charger->edev)) { 255 257 INIT_WORK(&charger->extcon_work, max8997_battery_extcon_evt_worker); 256 258 ret = devm_add_action(&pdev->dev, max8997_battery_extcon_evt_stop_work, charger); 257 259 if (ret) { ··· 267 263 if (ret) { 268 264 dev_err(&pdev->dev, "failed to register extcon notifier\n"); 269 265 return ret; 270 - }; 266 + } 271 267 } 272 268 273 269 return 0;
+3 -3
drivers/power/supply/pm2301_charger.c
··· 18 18 #include <linux/i2c.h> 19 19 #include <linux/workqueue.h> 20 20 #include <linux/mfd/abx500/ab8500.h> 21 - #include <linux/mfd/abx500/ab8500-bm.h> 22 - #include <linux/mfd/abx500/ux500_chargalg.h> 23 21 #include <linux/pm2301_charger.h> 24 22 #include <linux/gpio.h> 25 23 #include <linux/pm_runtime.h> 26 24 #include <linux/pm.h> 27 25 26 + #include "ab8500-bm.h" 27 + #include "ab8500-chargalg.h" 28 28 #include "pm2301_charger.h" 29 29 30 30 #define to_pm2xxx_charger_ac_device_info(x) container_of((x), \ ··· 1089 1089 ret = request_threaded_irq(gpio_to_irq(pm2->pdata->gpio_irq_number), 1090 1090 NULL, 1091 1091 pm2xxx_charger_irq[0].isr, 1092 - pm2->pdata->irq_type, 1092 + pm2->pdata->irq_type | IRQF_ONESHOT, 1093 1093 pm2xxx_charger_irq[0].name, pm2); 1094 1094 1095 1095 if (ret != 0) {
+2 -2
drivers/power/supply/power_supply_core.c
··· 169 169 break; 170 170 171 171 if (np == epsy->of_node) { 172 - dev_info(&psy->dev, "%s: Found supply : %s\n", 172 + dev_dbg(&psy->dev, "%s: Found supply : %s\n", 173 173 psy->desc->name, epsy->desc->name); 174 174 psy->supplied_from[i-1] = (char *)epsy->desc->name; 175 175 psy->num_supplies++; ··· 1143 1143 1144 1144 rc = power_supply_check_supplies(psy); 1145 1145 if (rc) { 1146 - dev_info(dev, "Not all required supplies found, defer probe\n"); 1146 + dev_dbg(dev, "Not all required supplies found, defer probe\n"); 1147 1147 goto check_supplies_failed; 1148 1148 } 1149 1149
+6 -15
drivers/power/supply/s3c_adc_battery.c
··· 1 - /* 2 - * iPAQ h1930/h1940/rx1950 battery controller driver 3 - * Copyright (c) Vasily Khoruzhick 4 - * Based on h1940_battery.c by Arnaud Patard 5 - * 6 - * This file is subject to the terms and conditions of the GNU General Public 7 - * License. See the file COPYING in the main directory of this archive for 8 - * more details. 9 - * 10 - */ 1 + // SPDX-License-Identifier: GPL-2.0 2 + // 3 + // iPAQ h1930/h1940/rx1950 battery controller driver 4 + // Copyright (c) Vasily Khoruzhick 5 + // Based on h1940_battery.c by Arnaud Patard 11 6 12 7 #include <linux/interrupt.h> 13 8 #include <linux/platform_device.h> ··· 390 395 if (main_bat.charge_finished) 391 396 free_irq(gpiod_to_irq(main_bat.charge_finished), NULL); 392 397 393 - cancel_delayed_work(&bat_work); 398 + cancel_delayed_work_sync(&bat_work); 394 399 395 400 if (pdata->exit) 396 401 pdata->exit(); ··· 402 407 static int s3c_adc_bat_suspend(struct platform_device *pdev, 403 408 pm_message_t state) 404 409 { 405 - struct s3c_adc_bat_pdata *pdata = pdev->dev.platform_data; 406 - 407 410 if (main_bat.charge_finished) { 408 411 if (device_may_wakeup(&pdev->dev)) 409 412 enable_irq_wake( ··· 417 424 418 425 static int s3c_adc_bat_resume(struct platform_device *pdev) 419 426 { 420 - struct s3c_adc_bat_pdata *pdata = pdev->dev.platform_data; 421 - 422 427 if (main_bat.charge_finished) { 423 428 if (device_may_wakeup(&pdev->dev)) 424 429 disable_irq_wake(
+9 -19
drivers/power/supply/sbs-battery.c
··· 1124 1124 1125 1125 chip->gpio_detect = devm_gpiod_get_optional(&client->dev, 1126 1126 "sbs,battery-detect", GPIOD_IN); 1127 - if (IS_ERR(chip->gpio_detect)) { 1128 - dev_err(&client->dev, "Failed to get gpio: %ld\n", 1129 - PTR_ERR(chip->gpio_detect)); 1130 - return PTR_ERR(chip->gpio_detect); 1131 - } 1127 + if (IS_ERR(chip->gpio_detect)) 1128 + return dev_err_probe(&client->dev, PTR_ERR(chip->gpio_detect), 1129 + "Failed to get gpio\n"); 1132 1130 1133 1131 i2c_set_clientdata(client, chip); 1134 1132 ··· 1157 1159 1158 1160 rc = sbs_get_battery_presence_and_health( 1159 1161 client, POWER_SUPPLY_PROP_PRESENT, &val); 1160 - if (rc < 0 || !val.intval) { 1161 - dev_err(&client->dev, "Failed to get present status\n"); 1162 - rc = -ENODEV; 1163 - goto exit_psupply; 1164 - } 1162 + if (rc < 0 || !val.intval) 1163 + return dev_err_probe(&client->dev, -ENODEV, 1164 + "Failed to get present status\n"); 1165 1165 } 1166 1166 1167 1167 rc = devm_delayed_work_autocancel(&client->dev, &chip->work, ··· 1169 1173 1170 1174 chip->power_supply = devm_power_supply_register(&client->dev, sbs_desc, 1171 1175 &psy_cfg); 1172 - if (IS_ERR(chip->power_supply)) { 1173 - dev_err(&client->dev, 1174 - "%s: Failed to register power supply\n", __func__); 1175 - rc = PTR_ERR(chip->power_supply); 1176 - goto exit_psupply; 1177 - } 1176 + if (IS_ERR(chip->power_supply)) 1177 + return dev_err_probe(&client->dev, PTR_ERR(chip->power_supply), 1178 + "Failed to register power supply\n"); 1178 1179 1179 1180 dev_info(&client->dev, 1180 1181 "%s: battery gas gauge device registered\n", client->name); 1181 1182 1182 1183 return 0; 1183 - 1184 - exit_psupply: 1185 - return rc; 1186 1184 } 1187 1185 1188 1186 #if defined CONFIG_PM_SLEEP
+8 -16
drivers/power/supply/sbs-charger.c
··· 16 16 #include <linux/i2c.h> 17 17 #include <linux/slab.h> 18 18 #include <linux/interrupt.h> 19 - #include <linux/gpio.h> 20 19 #include <linux/regmap.h> 21 - #include <linux/of_gpio.h> 22 20 #include <linux/bitops.h> 23 21 24 22 #define SBS_CHARGER_REG_SPEC_INFO 0x11 ··· 187 189 * to the battery. 188 190 */ 189 191 ret = regmap_read(chip->regmap, SBS_CHARGER_REG_STATUS, &val); 190 - if (ret) { 191 - dev_err(&client->dev, "Failed to get device status\n"); 192 - return ret; 193 - } 192 + if (ret) 193 + return dev_err_probe(&client->dev, ret, "Failed to get device status\n"); 194 194 chip->last_state = val; 195 195 196 - chip->power_supply = devm_power_supply_register(&client->dev, &sbs_desc, 197 - &psy_cfg); 198 - if (IS_ERR(chip->power_supply)) { 199 - dev_err(&client->dev, "Failed to register power supply\n"); 200 - return PTR_ERR(chip->power_supply); 201 - } 196 + chip->power_supply = devm_power_supply_register(&client->dev, &sbs_desc, &psy_cfg); 197 + if (IS_ERR(chip->power_supply)) 198 + return dev_err_probe(&client->dev, PTR_ERR(chip->power_supply), 199 + "Failed to register power supply\n"); 202 200 203 201 /* 204 202 * The sbs-charger spec doesn't impose the use of an interrupt. So in ··· 206 212 NULL, sbs_irq_thread, 207 213 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 208 214 dev_name(&client->dev), chip); 209 - if (ret) { 210 - dev_err(&client->dev, "Failed to request irq, %d\n", ret); 211 - return ret; 212 - } 215 + if (ret) 216 + return dev_err_probe(&client->dev, ret, "Failed to request irq\n"); 213 217 } else { 214 218 INIT_DELAYED_WORK(&chip->work, sbs_delayed_work); 215 219 schedule_delayed_work(&chip->work,
+28 -50
drivers/power/supply/sbs-manager.c
··· 13 13 * Karl-Heinz Schneider <karl-heinz@schneider-inet.de> 14 14 */ 15 15 16 - #include <linux/gpio.h> 16 + #include <linux/gpio/driver.h> 17 17 #include <linux/module.h> 18 18 #include <linux/i2c.h> 19 19 #include <linux/i2c-mux.h> ··· 294 294 gc->owner = THIS_MODULE; 295 295 296 296 ret = devm_gpiochip_add_data(dev, gc, data); 297 - if (ret) { 298 - dev_err(dev, "devm_gpiochip_add_data failed: %d\n", ret); 299 - return ret; 300 - } 297 + if (ret) 298 + return dev_err_probe(dev, ret, "devm_gpiochip_add_data failed\n"); 301 299 302 300 return ret; 303 301 } ··· 308 310 .set_property = &sbsm_set_property, 309 311 .property_is_writeable = &sbsm_prop_is_writeable, 310 312 }; 313 + 314 + static void sbsm_del_mux_adapter(void *data) 315 + { 316 + struct sbsm_data *sbsm = data; 317 + i2c_mux_del_adapters(sbsm->muxc); 318 + } 311 319 312 320 static int sbsm_probe(struct i2c_client *client, 313 321 const struct i2c_device_id *id) ··· 347 343 data->supported_bats = ret & SBSM_MASK_BAT_SUPPORTED; 348 344 data->muxc = i2c_mux_alloc(adapter, dev, SBSM_MAX_BATS, 0, 349 345 I2C_MUX_LOCKED, &sbsm_select, NULL); 350 - if (!data->muxc) { 351 - dev_err(dev, "failed to alloc i2c mux\n"); 352 - ret = -ENOMEM; 353 - goto err_mux_alloc; 354 - } 346 + if (!data->muxc) 347 + return dev_err_probe(dev, -ENOMEM, "failed to alloc i2c mux\n"); 355 348 data->muxc->priv = data; 349 + 350 + ret = devm_add_action_or_reset(dev, sbsm_del_mux_adapter, data); 351 + if (ret) 352 + return ret; 356 353 357 354 /* register muxed i2c channels. One for each supported battery */ 358 355 for (i = 0; i < SBSM_MAX_BATS; ++i) { ··· 363 358 break; 364 359 } 365 360 } 366 - if (ret) { 367 - dev_err(dev, "failed to register i2c mux channel %d\n", i + 1); 368 - goto err_mux_register; 369 - } 361 + if (ret) 362 + return dev_err_probe(dev, ret, "failed to register i2c mux channel %d\n", i + 1); 370 363 371 - psy_desc = devm_kmemdup(dev, &sbsm_default_psy_desc, 372 - sizeof(struct power_supply_desc), 373 - GFP_KERNEL); 374 - if (!psy_desc) { 375 - ret = -ENOMEM; 376 - goto err_psy; 377 - } 364 + psy_desc = devm_kmemdup(dev, &sbsm_default_psy_desc, sizeof(*psy_desc), GFP_KERNEL); 365 + if (!psy_desc) 366 + return -ENOMEM; 378 367 379 - psy_desc->name = devm_kasprintf(dev, GFP_KERNEL, "sbsm-%s", 380 - dev_name(&client->dev)); 381 - if (!psy_desc->name) { 382 - ret = -ENOMEM; 383 - goto err_psy; 384 - } 368 + psy_desc->name = devm_kasprintf(dev, GFP_KERNEL, "sbsm-%s", dev_name(&client->dev)); 369 + if (!psy_desc->name) 370 + return -ENOMEM; 371 + 385 372 ret = sbsm_gpio_setup(data); 386 373 if (ret < 0) 387 - goto err_psy; 374 + return ret; 388 375 389 376 psy_cfg.drv_data = data; 390 377 psy_cfg.of_node = dev->of_node; 391 378 data->psy = devm_power_supply_register(dev, psy_desc, &psy_cfg); 392 - if (IS_ERR(data->psy)) { 393 - ret = PTR_ERR(data->psy); 394 - dev_err(dev, "failed to register power supply %s\n", 395 - psy_desc->name); 396 - goto err_psy; 397 - } 379 + if (IS_ERR(data->psy)) 380 + return dev_err_probe(dev, PTR_ERR(data->psy), 381 + "failed to register power supply %s\n", psy_desc->name); 398 382 399 - return 0; 400 - 401 - err_psy: 402 - err_mux_register: 403 - i2c_mux_del_adapters(data->muxc); 404 - 405 - err_mux_alloc: 406 - return ret; 407 - } 408 - 409 - static int sbsm_remove(struct i2c_client *client) 410 - { 411 - struct sbsm_data *data = i2c_get_clientdata(client); 412 - 413 - i2c_mux_del_adapters(data->muxc); 414 383 return 0; 415 384 } 416 385 ··· 410 431 .of_match_table = of_match_ptr(sbsm_dt_ids), 411 432 }, 412 433 .probe = sbsm_probe, 413 - .remove = sbsm_remove, 414 434 .alert = sbsm_alert, 415 435 .id_table = sbsm_ids 416 436 };
+39 -26
drivers/power/supply/smb347-charger.c
··· 911 911 { 912 912 int ret; 913 913 914 - ret = devm_request_threaded_irq(smb->dev, client->irq, NULL, 915 - smb347_interrupt, IRQF_ONESHOT, 916 - client->name, smb); 917 - if (ret < 0) 918 - return ret; 914 + smb->irq_unsupported = true; 915 + 916 + /* 917 + * Interrupt pin is optional. If it is connected, we setup the 918 + * interrupt support here. 919 + */ 920 + if (!client->irq) 921 + return 0; 919 922 920 923 ret = smb347_set_writable(smb, true); 921 924 if (ret < 0) ··· 934 931 935 932 smb347_set_writable(smb, false); 936 933 937 - return ret; 934 + if (ret < 0) { 935 + dev_warn(smb->dev, "failed to initialize IRQ: %d\n", ret); 936 + dev_warn(smb->dev, "disabling IRQ support\n"); 937 + return 0; 938 + } 939 + 940 + ret = devm_request_threaded_irq(smb->dev, client->irq, NULL, 941 + smb347_interrupt, IRQF_ONESHOT, 942 + client->name, smb); 943 + if (ret) 944 + return ret; 945 + 946 + smb->irq_unsupported = false; 947 + 948 + ret = smb347_irq_enable(smb); 949 + if (ret < 0) 950 + return ret; 951 + 952 + return 0; 938 953 } 939 954 940 955 /* ··· 1141 1120 struct i2c_client *client = to_i2c_client(smb->dev); 1142 1121 int ret; 1143 1122 1144 - disable_irq(client->irq); 1123 + if (!smb->irq_unsupported) 1124 + disable_irq(client->irq); 1125 + 1145 1126 ret = smb347_get_property_locked(psy, prop, val); 1146 - enable_irq(client->irq); 1127 + 1128 + if (!smb->irq_unsupported) 1129 + enable_irq(client->irq); 1147 1130 1148 1131 return ret; 1149 1132 } ··· 1364 1339 if (ret < 0) 1365 1340 return ret; 1366 1341 1367 - /* 1368 - * Interrupt pin is optional. If it is connected, we setup the 1369 - * interrupt support here. 1370 - */ 1371 - if (client->irq) { 1372 - ret = smb347_irq_init(smb, client); 1373 - if (ret < 0) { 1374 - dev_warn(dev, "failed to initialize IRQ: %d\n", ret); 1375 - dev_warn(dev, "disabling IRQ support\n"); 1376 - smb->irq_unsupported = true; 1377 - } else { 1378 - smb347_irq_enable(smb); 1379 - } 1380 - } 1342 + ret = smb347_irq_init(smb, client); 1343 + if (ret) 1344 + return ret; 1381 1345 1382 1346 return 0; 1383 1347 } ··· 1401 1387 .name = "smb347", 1402 1388 .of_match_table = smb3xx_of_match, 1403 1389 }, 1404 - .probe = smb347_probe, 1405 - .remove = smb347_remove, 1406 - .id_table = smb347_id, 1390 + .probe = smb347_probe, 1391 + .remove = smb347_remove, 1392 + .id_table = smb347_id, 1407 1393 }; 1408 - 1409 1394 module_i2c_driver(smb347_driver); 1410 1395 1411 1396 MODULE_AUTHOR("Bruce E. Robertson <bruce.e.robertson@intel.com>");
+865
drivers/power/supply/surface_battery.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Battery driver for 7th-generation Microsoft Surface devices via Surface 4 + * System Aggregator Module (SSAM). 5 + * 6 + * Copyright (C) 2019-2021 Maximilian Luz <luzmaximilian@gmail.com> 7 + */ 8 + 9 + #include <asm/unaligned.h> 10 + #include <linux/jiffies.h> 11 + #include <linux/kernel.h> 12 + #include <linux/module.h> 13 + #include <linux/mutex.h> 14 + #include <linux/power_supply.h> 15 + #include <linux/sysfs.h> 16 + #include <linux/types.h> 17 + #include <linux/workqueue.h> 18 + 19 + #include <linux/surface_aggregator/device.h> 20 + 21 + 22 + /* -- SAM interface. -------------------------------------------------------- */ 23 + 24 + enum sam_event_cid_bat { 25 + SAM_EVENT_CID_BAT_BIX = 0x15, 26 + SAM_EVENT_CID_BAT_BST = 0x16, 27 + SAM_EVENT_CID_BAT_ADP = 0x17, 28 + SAM_EVENT_CID_BAT_PROT = 0x18, 29 + SAM_EVENT_CID_BAT_DPTF = 0x53, 30 + }; 31 + 32 + enum sam_battery_sta { 33 + SAM_BATTERY_STA_OK = 0x0f, 34 + SAM_BATTERY_STA_PRESENT = 0x10, 35 + }; 36 + 37 + enum sam_battery_state { 38 + SAM_BATTERY_STATE_DISCHARGING = BIT(0), 39 + SAM_BATTERY_STATE_CHARGING = BIT(1), 40 + SAM_BATTERY_STATE_CRITICAL = BIT(2), 41 + }; 42 + 43 + enum sam_battery_power_unit { 44 + SAM_BATTERY_POWER_UNIT_mW = 0, 45 + SAM_BATTERY_POWER_UNIT_mA = 1, 46 + }; 47 + 48 + /* Equivalent to data returned in ACPI _BIX method, revision 0. */ 49 + struct spwr_bix { 50 + u8 revision; 51 + __le32 power_unit; 52 + __le32 design_cap; 53 + __le32 last_full_charge_cap; 54 + __le32 technology; 55 + __le32 design_voltage; 56 + __le32 design_cap_warn; 57 + __le32 design_cap_low; 58 + __le32 cycle_count; 59 + __le32 measurement_accuracy; 60 + __le32 max_sampling_time; 61 + __le32 min_sampling_time; 62 + __le32 max_avg_interval; 63 + __le32 min_avg_interval; 64 + __le32 bat_cap_granularity_1; 65 + __le32 bat_cap_granularity_2; 66 + __u8 model[21]; 67 + __u8 serial[11]; 68 + __u8 type[5]; 69 + __u8 oem_info[21]; 70 + } __packed; 71 + 72 + static_assert(sizeof(struct spwr_bix) == 119); 73 + 74 + /* Equivalent to data returned in ACPI _BST method. */ 75 + struct spwr_bst { 76 + __le32 state; 77 + __le32 present_rate; 78 + __le32 remaining_cap; 79 + __le32 present_voltage; 80 + } __packed; 81 + 82 + static_assert(sizeof(struct spwr_bst) == 16); 83 + 84 + #define SPWR_BIX_REVISION 0 85 + #define SPWR_BATTERY_VALUE_UNKNOWN 0xffffffff 86 + 87 + /* Get battery status (_STA) */ 88 + SSAM_DEFINE_SYNC_REQUEST_CL_R(ssam_bat_get_sta, __le32, { 89 + .target_category = SSAM_SSH_TC_BAT, 90 + .command_id = 0x01, 91 + }); 92 + 93 + /* Get battery static information (_BIX). */ 94 + SSAM_DEFINE_SYNC_REQUEST_CL_R(ssam_bat_get_bix, struct spwr_bix, { 95 + .target_category = SSAM_SSH_TC_BAT, 96 + .command_id = 0x02, 97 + }); 98 + 99 + /* Get battery dynamic information (_BST). */ 100 + SSAM_DEFINE_SYNC_REQUEST_CL_R(ssam_bat_get_bst, struct spwr_bst, { 101 + .target_category = SSAM_SSH_TC_BAT, 102 + .command_id = 0x03, 103 + }); 104 + 105 + /* Set battery trip point (_BTP). */ 106 + SSAM_DEFINE_SYNC_REQUEST_CL_W(ssam_bat_set_btp, __le32, { 107 + .target_category = SSAM_SSH_TC_BAT, 108 + .command_id = 0x04, 109 + }); 110 + 111 + 112 + /* -- Device structures. ---------------------------------------------------- */ 113 + 114 + struct spwr_psy_properties { 115 + const char *name; 116 + struct ssam_event_registry registry; 117 + }; 118 + 119 + struct spwr_battery_device { 120 + struct ssam_device *sdev; 121 + 122 + char name[32]; 123 + struct power_supply *psy; 124 + struct power_supply_desc psy_desc; 125 + 126 + struct delayed_work update_work; 127 + 128 + struct ssam_event_notifier notif; 129 + 130 + struct mutex lock; /* Guards access to state data below. */ 131 + unsigned long timestamp; 132 + 133 + __le32 sta; 134 + struct spwr_bix bix; 135 + struct spwr_bst bst; 136 + u32 alarm; 137 + }; 138 + 139 + 140 + /* -- Module parameters. ---------------------------------------------------- */ 141 + 142 + static unsigned int cache_time = 1000; 143 + module_param(cache_time, uint, 0644); 144 + MODULE_PARM_DESC(cache_time, "battery state caching time in milliseconds [default: 1000]"); 145 + 146 + 147 + /* -- State management. ----------------------------------------------------- */ 148 + 149 + /* 150 + * Delay for battery update quirk. See spwr_external_power_changed() below 151 + * for more details. 152 + */ 153 + #define SPWR_AC_BAT_UPDATE_DELAY msecs_to_jiffies(5000) 154 + 155 + static bool spwr_battery_present(struct spwr_battery_device *bat) 156 + { 157 + lockdep_assert_held(&bat->lock); 158 + 159 + return le32_to_cpu(bat->sta) & SAM_BATTERY_STA_PRESENT; 160 + } 161 + 162 + static int spwr_battery_load_sta(struct spwr_battery_device *bat) 163 + { 164 + lockdep_assert_held(&bat->lock); 165 + 166 + return ssam_retry(ssam_bat_get_sta, bat->sdev, &bat->sta); 167 + } 168 + 169 + static int spwr_battery_load_bix(struct spwr_battery_device *bat) 170 + { 171 + int status; 172 + 173 + lockdep_assert_held(&bat->lock); 174 + 175 + if (!spwr_battery_present(bat)) 176 + return 0; 177 + 178 + status = ssam_retry(ssam_bat_get_bix, bat->sdev, &bat->bix); 179 + 180 + /* Enforce NULL terminated strings in case anything goes wrong... */ 181 + bat->bix.model[ARRAY_SIZE(bat->bix.model) - 1] = 0; 182 + bat->bix.serial[ARRAY_SIZE(bat->bix.serial) - 1] = 0; 183 + bat->bix.type[ARRAY_SIZE(bat->bix.type) - 1] = 0; 184 + bat->bix.oem_info[ARRAY_SIZE(bat->bix.oem_info) - 1] = 0; 185 + 186 + return status; 187 + } 188 + 189 + static int spwr_battery_load_bst(struct spwr_battery_device *bat) 190 + { 191 + lockdep_assert_held(&bat->lock); 192 + 193 + if (!spwr_battery_present(bat)) 194 + return 0; 195 + 196 + return ssam_retry(ssam_bat_get_bst, bat->sdev, &bat->bst); 197 + } 198 + 199 + static int spwr_battery_set_alarm_unlocked(struct spwr_battery_device *bat, u32 value) 200 + { 201 + __le32 value_le = cpu_to_le32(value); 202 + 203 + lockdep_assert_held(&bat->lock); 204 + 205 + bat->alarm = value; 206 + return ssam_retry(ssam_bat_set_btp, bat->sdev, &value_le); 207 + } 208 + 209 + static int spwr_battery_update_bst_unlocked(struct spwr_battery_device *bat, bool cached) 210 + { 211 + unsigned long cache_deadline = bat->timestamp + msecs_to_jiffies(cache_time); 212 + int status; 213 + 214 + lockdep_assert_held(&bat->lock); 215 + 216 + if (cached && bat->timestamp && time_is_after_jiffies(cache_deadline)) 217 + return 0; 218 + 219 + status = spwr_battery_load_sta(bat); 220 + if (status) 221 + return status; 222 + 223 + status = spwr_battery_load_bst(bat); 224 + if (status) 225 + return status; 226 + 227 + bat->timestamp = jiffies; 228 + return 0; 229 + } 230 + 231 + static int spwr_battery_update_bst(struct spwr_battery_device *bat, bool cached) 232 + { 233 + int status; 234 + 235 + mutex_lock(&bat->lock); 236 + status = spwr_battery_update_bst_unlocked(bat, cached); 237 + mutex_unlock(&bat->lock); 238 + 239 + return status; 240 + } 241 + 242 + static int spwr_battery_update_bix_unlocked(struct spwr_battery_device *bat) 243 + { 244 + int status; 245 + 246 + lockdep_assert_held(&bat->lock); 247 + 248 + status = spwr_battery_load_sta(bat); 249 + if (status) 250 + return status; 251 + 252 + status = spwr_battery_load_bix(bat); 253 + if (status) 254 + return status; 255 + 256 + status = spwr_battery_load_bst(bat); 257 + if (status) 258 + return status; 259 + 260 + if (bat->bix.revision != SPWR_BIX_REVISION) 261 + dev_warn(&bat->sdev->dev, "unsupported battery revision: %u\n", bat->bix.revision); 262 + 263 + bat->timestamp = jiffies; 264 + return 0; 265 + } 266 + 267 + static u32 sprw_battery_get_full_cap_safe(struct spwr_battery_device *bat) 268 + { 269 + u32 full_cap = get_unaligned_le32(&bat->bix.last_full_charge_cap); 270 + 271 + lockdep_assert_held(&bat->lock); 272 + 273 + if (full_cap == 0 || full_cap == SPWR_BATTERY_VALUE_UNKNOWN) 274 + full_cap = get_unaligned_le32(&bat->bix.design_cap); 275 + 276 + return full_cap; 277 + } 278 + 279 + static bool spwr_battery_is_full(struct spwr_battery_device *bat) 280 + { 281 + u32 state = get_unaligned_le32(&bat->bst.state); 282 + u32 full_cap = sprw_battery_get_full_cap_safe(bat); 283 + u32 remaining_cap = get_unaligned_le32(&bat->bst.remaining_cap); 284 + 285 + lockdep_assert_held(&bat->lock); 286 + 287 + return full_cap != SPWR_BATTERY_VALUE_UNKNOWN && full_cap != 0 && 288 + remaining_cap != SPWR_BATTERY_VALUE_UNKNOWN && 289 + remaining_cap >= full_cap && 290 + state == 0; 291 + } 292 + 293 + static int spwr_battery_recheck_full(struct spwr_battery_device *bat) 294 + { 295 + bool present; 296 + u32 unit; 297 + int status; 298 + 299 + mutex_lock(&bat->lock); 300 + unit = get_unaligned_le32(&bat->bix.power_unit); 301 + present = spwr_battery_present(bat); 302 + 303 + status = spwr_battery_update_bix_unlocked(bat); 304 + if (status) 305 + goto out; 306 + 307 + /* If battery has been attached, (re-)initialize alarm. */ 308 + if (!present && spwr_battery_present(bat)) { 309 + u32 cap_warn = get_unaligned_le32(&bat->bix.design_cap_warn); 310 + 311 + status = spwr_battery_set_alarm_unlocked(bat, cap_warn); 312 + if (status) 313 + goto out; 314 + } 315 + 316 + /* 317 + * Warn if the unit has changed. This is something we genuinely don't 318 + * expect to happen, so make this a big warning. If it does, we'll 319 + * need to add support for it. 320 + */ 321 + WARN_ON(unit != get_unaligned_le32(&bat->bix.power_unit)); 322 + 323 + out: 324 + mutex_unlock(&bat->lock); 325 + 326 + if (!status) 327 + power_supply_changed(bat->psy); 328 + 329 + return status; 330 + } 331 + 332 + static int spwr_battery_recheck_status(struct spwr_battery_device *bat) 333 + { 334 + int status; 335 + 336 + status = spwr_battery_update_bst(bat, false); 337 + if (!status) 338 + power_supply_changed(bat->psy); 339 + 340 + return status; 341 + } 342 + 343 + static u32 spwr_notify_bat(struct ssam_event_notifier *nf, const struct ssam_event *event) 344 + { 345 + struct spwr_battery_device *bat = container_of(nf, struct spwr_battery_device, notif); 346 + int status; 347 + 348 + dev_dbg(&bat->sdev->dev, "power event (cid = %#04x, iid = %#04x, tid = %#04x)\n", 349 + event->command_id, event->instance_id, event->target_id); 350 + 351 + switch (event->command_id) { 352 + case SAM_EVENT_CID_BAT_BIX: 353 + status = spwr_battery_recheck_full(bat); 354 + break; 355 + 356 + case SAM_EVENT_CID_BAT_BST: 357 + status = spwr_battery_recheck_status(bat); 358 + break; 359 + 360 + case SAM_EVENT_CID_BAT_PROT: 361 + /* 362 + * TODO: Implement support for battery protection status change 363 + * event. 364 + */ 365 + status = 0; 366 + break; 367 + 368 + case SAM_EVENT_CID_BAT_DPTF: 369 + /* 370 + * TODO: Implement support for DPTF event. 371 + */ 372 + status = 0; 373 + break; 374 + 375 + default: 376 + return 0; 377 + } 378 + 379 + return ssam_notifier_from_errno(status) | SSAM_NOTIF_HANDLED; 380 + } 381 + 382 + static void spwr_battery_update_bst_workfn(struct work_struct *work) 383 + { 384 + struct delayed_work *dwork = to_delayed_work(work); 385 + struct spwr_battery_device *bat; 386 + int status; 387 + 388 + bat = container_of(dwork, struct spwr_battery_device, update_work); 389 + 390 + status = spwr_battery_update_bst(bat, false); 391 + if (status) { 392 + dev_err(&bat->sdev->dev, "failed to update battery state: %d\n", status); 393 + return; 394 + } 395 + 396 + power_supply_changed(bat->psy); 397 + } 398 + 399 + static void spwr_external_power_changed(struct power_supply *psy) 400 + { 401 + struct spwr_battery_device *bat = power_supply_get_drvdata(psy); 402 + 403 + /* 404 + * Handle battery update quirk: When the battery is fully charged (or 405 + * charged up to the limit imposed by the UEFI battery limit) and the 406 + * adapter is plugged in or removed, the EC does not send a separate 407 + * event for the state (charging/discharging) change. Furthermore it 408 + * may take some time until the state is updated on the battery. 409 + * Schedule an update to solve this. 410 + */ 411 + 412 + schedule_delayed_work(&bat->update_work, SPWR_AC_BAT_UPDATE_DELAY); 413 + } 414 + 415 + 416 + /* -- Properties. ----------------------------------------------------------- */ 417 + 418 + static const enum power_supply_property spwr_battery_props_chg[] = { 419 + POWER_SUPPLY_PROP_STATUS, 420 + POWER_SUPPLY_PROP_PRESENT, 421 + POWER_SUPPLY_PROP_TECHNOLOGY, 422 + POWER_SUPPLY_PROP_CYCLE_COUNT, 423 + POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 424 + POWER_SUPPLY_PROP_VOLTAGE_NOW, 425 + POWER_SUPPLY_PROP_CURRENT_NOW, 426 + POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, 427 + POWER_SUPPLY_PROP_CHARGE_FULL, 428 + POWER_SUPPLY_PROP_CHARGE_NOW, 429 + POWER_SUPPLY_PROP_CAPACITY, 430 + POWER_SUPPLY_PROP_CAPACITY_LEVEL, 431 + POWER_SUPPLY_PROP_MODEL_NAME, 432 + POWER_SUPPLY_PROP_MANUFACTURER, 433 + POWER_SUPPLY_PROP_SERIAL_NUMBER, 434 + }; 435 + 436 + static const enum power_supply_property spwr_battery_props_eng[] = { 437 + POWER_SUPPLY_PROP_STATUS, 438 + POWER_SUPPLY_PROP_PRESENT, 439 + POWER_SUPPLY_PROP_TECHNOLOGY, 440 + POWER_SUPPLY_PROP_CYCLE_COUNT, 441 + POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 442 + POWER_SUPPLY_PROP_VOLTAGE_NOW, 443 + POWER_SUPPLY_PROP_POWER_NOW, 444 + POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, 445 + POWER_SUPPLY_PROP_ENERGY_FULL, 446 + POWER_SUPPLY_PROP_ENERGY_NOW, 447 + POWER_SUPPLY_PROP_CAPACITY, 448 + POWER_SUPPLY_PROP_CAPACITY_LEVEL, 449 + POWER_SUPPLY_PROP_MODEL_NAME, 450 + POWER_SUPPLY_PROP_MANUFACTURER, 451 + POWER_SUPPLY_PROP_SERIAL_NUMBER, 452 + }; 453 + 454 + static int spwr_battery_prop_status(struct spwr_battery_device *bat) 455 + { 456 + u32 state = get_unaligned_le32(&bat->bst.state); 457 + u32 present_rate = get_unaligned_le32(&bat->bst.present_rate); 458 + 459 + lockdep_assert_held(&bat->lock); 460 + 461 + if (state & SAM_BATTERY_STATE_DISCHARGING) 462 + return POWER_SUPPLY_STATUS_DISCHARGING; 463 + 464 + if (state & SAM_BATTERY_STATE_CHARGING) 465 + return POWER_SUPPLY_STATUS_CHARGING; 466 + 467 + if (spwr_battery_is_full(bat)) 468 + return POWER_SUPPLY_STATUS_FULL; 469 + 470 + if (present_rate == 0) 471 + return POWER_SUPPLY_STATUS_NOT_CHARGING; 472 + 473 + return POWER_SUPPLY_STATUS_UNKNOWN; 474 + } 475 + 476 + static int spwr_battery_prop_technology(struct spwr_battery_device *bat) 477 + { 478 + lockdep_assert_held(&bat->lock); 479 + 480 + if (!strcasecmp("NiCd", bat->bix.type)) 481 + return POWER_SUPPLY_TECHNOLOGY_NiCd; 482 + 483 + if (!strcasecmp("NiMH", bat->bix.type)) 484 + return POWER_SUPPLY_TECHNOLOGY_NiMH; 485 + 486 + if (!strcasecmp("LION", bat->bix.type)) 487 + return POWER_SUPPLY_TECHNOLOGY_LION; 488 + 489 + if (!strncasecmp("LI-ION", bat->bix.type, 6)) 490 + return POWER_SUPPLY_TECHNOLOGY_LION; 491 + 492 + if (!strcasecmp("LiP", bat->bix.type)) 493 + return POWER_SUPPLY_TECHNOLOGY_LIPO; 494 + 495 + return POWER_SUPPLY_TECHNOLOGY_UNKNOWN; 496 + } 497 + 498 + static int spwr_battery_prop_capacity(struct spwr_battery_device *bat) 499 + { 500 + u32 full_cap = sprw_battery_get_full_cap_safe(bat); 501 + u32 remaining_cap = get_unaligned_le32(&bat->bst.remaining_cap); 502 + 503 + lockdep_assert_held(&bat->lock); 504 + 505 + if (full_cap == 0 || full_cap == SPWR_BATTERY_VALUE_UNKNOWN) 506 + return -ENODATA; 507 + 508 + if (remaining_cap == SPWR_BATTERY_VALUE_UNKNOWN) 509 + return -ENODATA; 510 + 511 + return remaining_cap * 100 / full_cap; 512 + } 513 + 514 + static int spwr_battery_prop_capacity_level(struct spwr_battery_device *bat) 515 + { 516 + u32 state = get_unaligned_le32(&bat->bst.state); 517 + u32 remaining_cap = get_unaligned_le32(&bat->bst.remaining_cap); 518 + 519 + lockdep_assert_held(&bat->lock); 520 + 521 + if (state & SAM_BATTERY_STATE_CRITICAL) 522 + return POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL; 523 + 524 + if (spwr_battery_is_full(bat)) 525 + return POWER_SUPPLY_CAPACITY_LEVEL_FULL; 526 + 527 + if (remaining_cap <= bat->alarm) 528 + return POWER_SUPPLY_CAPACITY_LEVEL_LOW; 529 + 530 + return POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; 531 + } 532 + 533 + static int spwr_battery_get_property(struct power_supply *psy, enum power_supply_property psp, 534 + union power_supply_propval *val) 535 + { 536 + struct spwr_battery_device *bat = power_supply_get_drvdata(psy); 537 + u32 value; 538 + int status; 539 + 540 + mutex_lock(&bat->lock); 541 + 542 + status = spwr_battery_update_bst_unlocked(bat, true); 543 + if (status) 544 + goto out; 545 + 546 + /* Abort if battery is not present. */ 547 + if (!spwr_battery_present(bat) && psp != POWER_SUPPLY_PROP_PRESENT) { 548 + status = -ENODEV; 549 + goto out; 550 + } 551 + 552 + switch (psp) { 553 + case POWER_SUPPLY_PROP_STATUS: 554 + val->intval = spwr_battery_prop_status(bat); 555 + break; 556 + 557 + case POWER_SUPPLY_PROP_PRESENT: 558 + val->intval = spwr_battery_present(bat); 559 + break; 560 + 561 + case POWER_SUPPLY_PROP_TECHNOLOGY: 562 + val->intval = spwr_battery_prop_technology(bat); 563 + break; 564 + 565 + case POWER_SUPPLY_PROP_CYCLE_COUNT: 566 + value = get_unaligned_le32(&bat->bix.cycle_count); 567 + if (value != SPWR_BATTERY_VALUE_UNKNOWN) 568 + val->intval = value; 569 + else 570 + status = -ENODATA; 571 + break; 572 + 573 + case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: 574 + value = get_unaligned_le32(&bat->bix.design_voltage); 575 + if (value != SPWR_BATTERY_VALUE_UNKNOWN) 576 + val->intval = value * 1000; 577 + else 578 + status = -ENODATA; 579 + break; 580 + 581 + case POWER_SUPPLY_PROP_VOLTAGE_NOW: 582 + value = get_unaligned_le32(&bat->bst.present_voltage); 583 + if (value != SPWR_BATTERY_VALUE_UNKNOWN) 584 + val->intval = value * 1000; 585 + else 586 + status = -ENODATA; 587 + break; 588 + 589 + case POWER_SUPPLY_PROP_CURRENT_NOW: 590 + case POWER_SUPPLY_PROP_POWER_NOW: 591 + value = get_unaligned_le32(&bat->bst.present_rate); 592 + if (value != SPWR_BATTERY_VALUE_UNKNOWN) 593 + val->intval = value * 1000; 594 + else 595 + status = -ENODATA; 596 + break; 597 + 598 + case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: 599 + case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: 600 + value = get_unaligned_le32(&bat->bix.design_cap); 601 + if (value != SPWR_BATTERY_VALUE_UNKNOWN) 602 + val->intval = value * 1000; 603 + else 604 + status = -ENODATA; 605 + break; 606 + 607 + case POWER_SUPPLY_PROP_CHARGE_FULL: 608 + case POWER_SUPPLY_PROP_ENERGY_FULL: 609 + value = get_unaligned_le32(&bat->bix.last_full_charge_cap); 610 + if (value != SPWR_BATTERY_VALUE_UNKNOWN) 611 + val->intval = value * 1000; 612 + else 613 + status = -ENODATA; 614 + break; 615 + 616 + case POWER_SUPPLY_PROP_CHARGE_NOW: 617 + case POWER_SUPPLY_PROP_ENERGY_NOW: 618 + value = get_unaligned_le32(&bat->bst.remaining_cap); 619 + if (value != SPWR_BATTERY_VALUE_UNKNOWN) 620 + val->intval = value * 1000; 621 + else 622 + status = -ENODATA; 623 + break; 624 + 625 + case POWER_SUPPLY_PROP_CAPACITY: 626 + val->intval = spwr_battery_prop_capacity(bat); 627 + break; 628 + 629 + case POWER_SUPPLY_PROP_CAPACITY_LEVEL: 630 + val->intval = spwr_battery_prop_capacity_level(bat); 631 + break; 632 + 633 + case POWER_SUPPLY_PROP_MODEL_NAME: 634 + val->strval = bat->bix.model; 635 + break; 636 + 637 + case POWER_SUPPLY_PROP_MANUFACTURER: 638 + val->strval = bat->bix.oem_info; 639 + break; 640 + 641 + case POWER_SUPPLY_PROP_SERIAL_NUMBER: 642 + val->strval = bat->bix.serial; 643 + break; 644 + 645 + default: 646 + status = -EINVAL; 647 + break; 648 + } 649 + 650 + out: 651 + mutex_unlock(&bat->lock); 652 + return status; 653 + } 654 + 655 + 656 + /* -- Alarm attribute. ------------------------------------------------------ */ 657 + 658 + static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, char *buf) 659 + { 660 + struct power_supply *psy = dev_get_drvdata(dev); 661 + struct spwr_battery_device *bat = power_supply_get_drvdata(psy); 662 + int status; 663 + 664 + mutex_lock(&bat->lock); 665 + status = sysfs_emit(buf, "%d\n", bat->alarm * 1000); 666 + mutex_unlock(&bat->lock); 667 + 668 + return status; 669 + } 670 + 671 + static ssize_t alarm_store(struct device *dev, struct device_attribute *attr, const char *buf, 672 + size_t count) 673 + { 674 + struct power_supply *psy = dev_get_drvdata(dev); 675 + struct spwr_battery_device *bat = power_supply_get_drvdata(psy); 676 + unsigned long value; 677 + int status; 678 + 679 + status = kstrtoul(buf, 0, &value); 680 + if (status) 681 + return status; 682 + 683 + mutex_lock(&bat->lock); 684 + 685 + if (!spwr_battery_present(bat)) { 686 + mutex_unlock(&bat->lock); 687 + return -ENODEV; 688 + } 689 + 690 + status = spwr_battery_set_alarm_unlocked(bat, value / 1000); 691 + if (status) { 692 + mutex_unlock(&bat->lock); 693 + return status; 694 + } 695 + 696 + mutex_unlock(&bat->lock); 697 + return count; 698 + } 699 + 700 + static DEVICE_ATTR_RW(alarm); 701 + 702 + static struct attribute *spwr_battery_attrs[] = { 703 + &dev_attr_alarm.attr, 704 + NULL, 705 + }; 706 + ATTRIBUTE_GROUPS(spwr_battery); 707 + 708 + 709 + /* -- Device setup. --------------------------------------------------------- */ 710 + 711 + static void spwr_battery_init(struct spwr_battery_device *bat, struct ssam_device *sdev, 712 + struct ssam_event_registry registry, const char *name) 713 + { 714 + mutex_init(&bat->lock); 715 + strncpy(bat->name, name, ARRAY_SIZE(bat->name) - 1); 716 + 717 + bat->sdev = sdev; 718 + 719 + bat->notif.base.priority = 1; 720 + bat->notif.base.fn = spwr_notify_bat; 721 + bat->notif.event.reg = registry; 722 + bat->notif.event.id.target_category = sdev->uid.category; 723 + bat->notif.event.id.instance = 0; 724 + bat->notif.event.mask = SSAM_EVENT_MASK_STRICT; 725 + bat->notif.event.flags = SSAM_EVENT_SEQUENCED; 726 + 727 + bat->psy_desc.name = bat->name; 728 + bat->psy_desc.type = POWER_SUPPLY_TYPE_BATTERY; 729 + bat->psy_desc.get_property = spwr_battery_get_property; 730 + 731 + INIT_DELAYED_WORK(&bat->update_work, spwr_battery_update_bst_workfn); 732 + } 733 + 734 + static int spwr_battery_register(struct spwr_battery_device *bat) 735 + { 736 + struct power_supply_config psy_cfg = {}; 737 + __le32 sta; 738 + int status; 739 + 740 + /* Make sure the device is there and functioning properly. */ 741 + status = ssam_retry(ssam_bat_get_sta, bat->sdev, &sta); 742 + if (status) 743 + return status; 744 + 745 + if ((le32_to_cpu(sta) & SAM_BATTERY_STA_OK) != SAM_BATTERY_STA_OK) 746 + return -ENODEV; 747 + 748 + /* Satisfy lockdep although we are in an exclusive context here. */ 749 + mutex_lock(&bat->lock); 750 + 751 + status = spwr_battery_update_bix_unlocked(bat); 752 + if (status) { 753 + mutex_unlock(&bat->lock); 754 + return status; 755 + } 756 + 757 + if (spwr_battery_present(bat)) { 758 + u32 cap_warn = get_unaligned_le32(&bat->bix.design_cap_warn); 759 + 760 + status = spwr_battery_set_alarm_unlocked(bat, cap_warn); 761 + if (status) { 762 + mutex_unlock(&bat->lock); 763 + return status; 764 + } 765 + } 766 + 767 + mutex_unlock(&bat->lock); 768 + 769 + bat->psy_desc.external_power_changed = spwr_external_power_changed; 770 + 771 + switch (get_unaligned_le32(&bat->bix.power_unit)) { 772 + case SAM_BATTERY_POWER_UNIT_mW: 773 + bat->psy_desc.properties = spwr_battery_props_eng; 774 + bat->psy_desc.num_properties = ARRAY_SIZE(spwr_battery_props_eng); 775 + break; 776 + 777 + case SAM_BATTERY_POWER_UNIT_mA: 778 + bat->psy_desc.properties = spwr_battery_props_chg; 779 + bat->psy_desc.num_properties = ARRAY_SIZE(spwr_battery_props_chg); 780 + break; 781 + 782 + default: 783 + dev_err(&bat->sdev->dev, "unsupported battery power unit: %u\n", 784 + get_unaligned_le32(&bat->bix.power_unit)); 785 + return -EINVAL; 786 + } 787 + 788 + psy_cfg.drv_data = bat; 789 + psy_cfg.attr_grp = spwr_battery_groups; 790 + 791 + bat->psy = devm_power_supply_register(&bat->sdev->dev, &bat->psy_desc, &psy_cfg); 792 + if (IS_ERR(bat->psy)) 793 + return PTR_ERR(bat->psy); 794 + 795 + return ssam_notifier_register(bat->sdev->ctrl, &bat->notif); 796 + } 797 + 798 + 799 + /* -- Driver setup. --------------------------------------------------------- */ 800 + 801 + static int __maybe_unused surface_battery_resume(struct device *dev) 802 + { 803 + return spwr_battery_recheck_full(dev_get_drvdata(dev)); 804 + } 805 + static SIMPLE_DEV_PM_OPS(surface_battery_pm_ops, NULL, surface_battery_resume); 806 + 807 + static int surface_battery_probe(struct ssam_device *sdev) 808 + { 809 + const struct spwr_psy_properties *p; 810 + struct spwr_battery_device *bat; 811 + 812 + p = ssam_device_get_match_data(sdev); 813 + if (!p) 814 + return -ENODEV; 815 + 816 + bat = devm_kzalloc(&sdev->dev, sizeof(*bat), GFP_KERNEL); 817 + if (!bat) 818 + return -ENOMEM; 819 + 820 + spwr_battery_init(bat, sdev, p->registry, p->name); 821 + ssam_device_set_drvdata(sdev, bat); 822 + 823 + return spwr_battery_register(bat); 824 + } 825 + 826 + static void surface_battery_remove(struct ssam_device *sdev) 827 + { 828 + struct spwr_battery_device *bat = ssam_device_get_drvdata(sdev); 829 + 830 + ssam_notifier_unregister(sdev->ctrl, &bat->notif); 831 + cancel_delayed_work_sync(&bat->update_work); 832 + } 833 + 834 + static const struct spwr_psy_properties spwr_psy_props_bat1 = { 835 + .name = "BAT1", 836 + .registry = SSAM_EVENT_REGISTRY_SAM, 837 + }; 838 + 839 + static const struct spwr_psy_properties spwr_psy_props_bat2_sb3 = { 840 + .name = "BAT2", 841 + .registry = SSAM_EVENT_REGISTRY_KIP, 842 + }; 843 + 844 + static const struct ssam_device_id surface_battery_match[] = { 845 + { SSAM_SDEV(BAT, 0x01, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat1 }, 846 + { SSAM_SDEV(BAT, 0x02, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat2_sb3 }, 847 + { }, 848 + }; 849 + MODULE_DEVICE_TABLE(ssam, surface_battery_match); 850 + 851 + static struct ssam_device_driver surface_battery_driver = { 852 + .probe = surface_battery_probe, 853 + .remove = surface_battery_remove, 854 + .match_table = surface_battery_match, 855 + .driver = { 856 + .name = "surface_battery", 857 + .pm = &surface_battery_pm_ops, 858 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 859 + }, 860 + }; 861 + module_ssam_device_driver(surface_battery_driver); 862 + 863 + MODULE_AUTHOR("Maximilian Luz <luzmaximilian@gmail.com>"); 864 + MODULE_DESCRIPTION("Battery driver for Surface System Aggregator Module"); 865 + MODULE_LICENSE("GPL");
+282
drivers/power/supply/surface_charger.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * AC driver for 7th-generation Microsoft Surface devices via Surface System 4 + * Aggregator Module (SSAM). 5 + * 6 + * Copyright (C) 2019-2021 Maximilian Luz <luzmaximilian@gmail.com> 7 + */ 8 + 9 + #include <asm/unaligned.h> 10 + #include <linux/kernel.h> 11 + #include <linux/module.h> 12 + #include <linux/mutex.h> 13 + #include <linux/power_supply.h> 14 + #include <linux/types.h> 15 + 16 + #include <linux/surface_aggregator/device.h> 17 + 18 + 19 + /* -- SAM interface. -------------------------------------------------------- */ 20 + 21 + enum sam_event_cid_bat { 22 + SAM_EVENT_CID_BAT_ADP = 0x17, 23 + }; 24 + 25 + enum sam_battery_sta { 26 + SAM_BATTERY_STA_OK = 0x0f, 27 + SAM_BATTERY_STA_PRESENT = 0x10, 28 + }; 29 + 30 + /* Get battery status (_STA). */ 31 + SSAM_DEFINE_SYNC_REQUEST_CL_R(ssam_bat_get_sta, __le32, { 32 + .target_category = SSAM_SSH_TC_BAT, 33 + .command_id = 0x01, 34 + }); 35 + 36 + /* Get platform power source for battery (_PSR / DPTF PSRC). */ 37 + SSAM_DEFINE_SYNC_REQUEST_CL_R(ssam_bat_get_psrc, __le32, { 38 + .target_category = SSAM_SSH_TC_BAT, 39 + .command_id = 0x0d, 40 + }); 41 + 42 + 43 + /* -- Device structures. ---------------------------------------------------- */ 44 + 45 + struct spwr_psy_properties { 46 + const char *name; 47 + struct ssam_event_registry registry; 48 + }; 49 + 50 + struct spwr_ac_device { 51 + struct ssam_device *sdev; 52 + 53 + char name[32]; 54 + struct power_supply *psy; 55 + struct power_supply_desc psy_desc; 56 + 57 + struct ssam_event_notifier notif; 58 + 59 + struct mutex lock; /* Guards access to state below. */ 60 + 61 + __le32 state; 62 + }; 63 + 64 + 65 + /* -- State management. ----------------------------------------------------- */ 66 + 67 + static int spwr_ac_update_unlocked(struct spwr_ac_device *ac) 68 + { 69 + u32 old = ac->state; 70 + int status; 71 + 72 + lockdep_assert_held(&ac->lock); 73 + 74 + status = ssam_retry(ssam_bat_get_psrc, ac->sdev, &ac->state); 75 + if (status < 0) 76 + return status; 77 + 78 + return old != ac->state; 79 + } 80 + 81 + static int spwr_ac_update(struct spwr_ac_device *ac) 82 + { 83 + int status; 84 + 85 + mutex_lock(&ac->lock); 86 + status = spwr_ac_update_unlocked(ac); 87 + mutex_unlock(&ac->lock); 88 + 89 + return status; 90 + } 91 + 92 + static int spwr_ac_recheck(struct spwr_ac_device *ac) 93 + { 94 + int status; 95 + 96 + status = spwr_ac_update(ac); 97 + if (status > 0) 98 + power_supply_changed(ac->psy); 99 + 100 + return status >= 0 ? 0 : status; 101 + } 102 + 103 + static u32 spwr_notify_ac(struct ssam_event_notifier *nf, const struct ssam_event *event) 104 + { 105 + struct spwr_ac_device *ac; 106 + int status; 107 + 108 + ac = container_of(nf, struct spwr_ac_device, notif); 109 + 110 + dev_dbg(&ac->sdev->dev, "power event (cid = %#04x, iid = %#04x, tid = %#04x)\n", 111 + event->command_id, event->instance_id, event->target_id); 112 + 113 + /* 114 + * Allow events of all targets/instances here. Global adapter status 115 + * seems to be handled via target=1 and instance=1, but events are 116 + * reported on all targets/instances in use. 117 + * 118 + * While it should be enough to just listen on 1/1, listen everywhere to 119 + * make sure we don't miss anything. 120 + */ 121 + 122 + switch (event->command_id) { 123 + case SAM_EVENT_CID_BAT_ADP: 124 + status = spwr_ac_recheck(ac); 125 + return ssam_notifier_from_errno(status) | SSAM_NOTIF_HANDLED; 126 + 127 + default: 128 + return 0; 129 + } 130 + } 131 + 132 + 133 + /* -- Properties. ----------------------------------------------------------- */ 134 + 135 + static const enum power_supply_property spwr_ac_props[] = { 136 + POWER_SUPPLY_PROP_ONLINE, 137 + }; 138 + 139 + static int spwr_ac_get_property(struct power_supply *psy, enum power_supply_property psp, 140 + union power_supply_propval *val) 141 + { 142 + struct spwr_ac_device *ac = power_supply_get_drvdata(psy); 143 + int status; 144 + 145 + mutex_lock(&ac->lock); 146 + 147 + status = spwr_ac_update_unlocked(ac); 148 + if (status) 149 + goto out; 150 + 151 + switch (psp) { 152 + case POWER_SUPPLY_PROP_ONLINE: 153 + val->intval = !!le32_to_cpu(ac->state); 154 + break; 155 + 156 + default: 157 + status = -EINVAL; 158 + goto out; 159 + } 160 + 161 + out: 162 + mutex_unlock(&ac->lock); 163 + return status; 164 + } 165 + 166 + 167 + /* -- Device setup. --------------------------------------------------------- */ 168 + 169 + static char *battery_supplied_to[] = { 170 + "BAT1", 171 + "BAT2", 172 + }; 173 + 174 + static void spwr_ac_init(struct spwr_ac_device *ac, struct ssam_device *sdev, 175 + struct ssam_event_registry registry, const char *name) 176 + { 177 + mutex_init(&ac->lock); 178 + strncpy(ac->name, name, ARRAY_SIZE(ac->name) - 1); 179 + 180 + ac->sdev = sdev; 181 + 182 + ac->notif.base.priority = 1; 183 + ac->notif.base.fn = spwr_notify_ac; 184 + ac->notif.event.reg = registry; 185 + ac->notif.event.id.target_category = sdev->uid.category; 186 + ac->notif.event.id.instance = 0; 187 + ac->notif.event.mask = SSAM_EVENT_MASK_NONE; 188 + ac->notif.event.flags = SSAM_EVENT_SEQUENCED; 189 + 190 + ac->psy_desc.name = ac->name; 191 + ac->psy_desc.type = POWER_SUPPLY_TYPE_MAINS; 192 + ac->psy_desc.properties = spwr_ac_props; 193 + ac->psy_desc.num_properties = ARRAY_SIZE(spwr_ac_props); 194 + ac->psy_desc.get_property = spwr_ac_get_property; 195 + } 196 + 197 + static int spwr_ac_register(struct spwr_ac_device *ac) 198 + { 199 + struct power_supply_config psy_cfg = {}; 200 + __le32 sta; 201 + int status; 202 + 203 + /* Make sure the device is there and functioning properly. */ 204 + status = ssam_retry(ssam_bat_get_sta, ac->sdev, &sta); 205 + if (status) 206 + return status; 207 + 208 + if ((le32_to_cpu(sta) & SAM_BATTERY_STA_OK) != SAM_BATTERY_STA_OK) 209 + return -ENODEV; 210 + 211 + psy_cfg.drv_data = ac; 212 + psy_cfg.supplied_to = battery_supplied_to; 213 + psy_cfg.num_supplicants = ARRAY_SIZE(battery_supplied_to); 214 + 215 + ac->psy = devm_power_supply_register(&ac->sdev->dev, &ac->psy_desc, &psy_cfg); 216 + if (IS_ERR(ac->psy)) 217 + return PTR_ERR(ac->psy); 218 + 219 + return ssam_notifier_register(ac->sdev->ctrl, &ac->notif); 220 + } 221 + 222 + 223 + /* -- Driver setup. --------------------------------------------------------- */ 224 + 225 + static int __maybe_unused surface_ac_resume(struct device *dev) 226 + { 227 + return spwr_ac_recheck(dev_get_drvdata(dev)); 228 + } 229 + static SIMPLE_DEV_PM_OPS(surface_ac_pm_ops, NULL, surface_ac_resume); 230 + 231 + static int surface_ac_probe(struct ssam_device *sdev) 232 + { 233 + const struct spwr_psy_properties *p; 234 + struct spwr_ac_device *ac; 235 + 236 + p = ssam_device_get_match_data(sdev); 237 + if (!p) 238 + return -ENODEV; 239 + 240 + ac = devm_kzalloc(&sdev->dev, sizeof(*ac), GFP_KERNEL); 241 + if (!ac) 242 + return -ENOMEM; 243 + 244 + spwr_ac_init(ac, sdev, p->registry, p->name); 245 + ssam_device_set_drvdata(sdev, ac); 246 + 247 + return spwr_ac_register(ac); 248 + } 249 + 250 + static void surface_ac_remove(struct ssam_device *sdev) 251 + { 252 + struct spwr_ac_device *ac = ssam_device_get_drvdata(sdev); 253 + 254 + ssam_notifier_unregister(sdev->ctrl, &ac->notif); 255 + } 256 + 257 + static const struct spwr_psy_properties spwr_psy_props_adp1 = { 258 + .name = "ADP1", 259 + .registry = SSAM_EVENT_REGISTRY_SAM, 260 + }; 261 + 262 + static const struct ssam_device_id surface_ac_match[] = { 263 + { SSAM_SDEV(BAT, 0x01, 0x01, 0x01), (unsigned long)&spwr_psy_props_adp1 }, 264 + { }, 265 + }; 266 + MODULE_DEVICE_TABLE(ssam, surface_ac_match); 267 + 268 + static struct ssam_device_driver surface_ac_driver = { 269 + .probe = surface_ac_probe, 270 + .remove = surface_ac_remove, 271 + .match_table = surface_ac_match, 272 + .driver = { 273 + .name = "surface_ac", 274 + .pm = &surface_ac_pm_ops, 275 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 276 + }, 277 + }; 278 + module_ssam_device_driver(surface_ac_driver); 279 + 280 + MODULE_AUTHOR("Maximilian Luz <luzmaximilian@gmail.com>"); 281 + MODULE_DESCRIPTION("AC driver for Surface System Aggregator Module"); 282 + MODULE_LICENSE("GPL");
+1 -1
drivers/power/supply/tps65090-charger.c
··· 301 301 302 302 if (irq != -ENXIO) { 303 303 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 304 - tps65090_charger_isr, 0, "tps65090-charger", cdata); 304 + tps65090_charger_isr, IRQF_ONESHOT, "tps65090-charger", cdata); 305 305 if (ret) { 306 306 dev_err(cdata->dev, 307 307 "Unable to register irq %d err %d\n", irq,
+1 -1
drivers/power/supply/tps65217_charger.c
··· 238 238 for (i = 0; i < NUM_CHARGER_IRQS; i++) { 239 239 ret = devm_request_threaded_irq(&pdev->dev, irq[i], NULL, 240 240 tps65217_charger_irq, 241 - 0, "tps65217-charger", 241 + IRQF_ONESHOT, "tps65217-charger", 242 242 charger); 243 243 if (ret) { 244 244 dev_err(charger->dev,
-3
drivers/power/supply/z2_battery.c
··· 90 90 static void z2_batt_update(struct z2_charger *charger) 91 91 { 92 92 int old_status = charger->bat_status; 93 - struct z2_battery_info *info; 94 - 95 - info = charger->info; 96 93 97 94 mutex_lock(&charger->work_lock); 98 95
-276
include/linux/mfd/abx500.h
··· 28 28 u8 setting; 29 29 }; 30 30 31 - /* Battery driver related data */ 32 - /* 33 - * ADC for the battery thermistor. 34 - * When using the ABx500_ADC_THERM_BATCTRL the battery ID resistor is combined 35 - * with a NTC resistor to both identify the battery and to measure its 36 - * temperature. Different phone manufactures uses different techniques to both 37 - * identify the battery and to read its temperature. 38 - */ 39 - enum abx500_adc_therm { 40 - ABx500_ADC_THERM_BATCTRL, 41 - ABx500_ADC_THERM_BATTEMP, 42 - }; 43 - 44 - /** 45 - * struct abx500_res_to_temp - defines one point in a temp to res curve. To 46 - * be used in battery packs that combines the identification resistor with a 47 - * NTC resistor. 48 - * @temp: battery pack temperature in Celsius 49 - * @resist: NTC resistor net total resistance 50 - */ 51 - struct abx500_res_to_temp { 52 - int temp; 53 - int resist; 54 - }; 55 - 56 - /** 57 - * struct abx500_v_to_cap - Table for translating voltage to capacity 58 - * @voltage: Voltage in mV 59 - * @capacity: Capacity in percent 60 - */ 61 - struct abx500_v_to_cap { 62 - int voltage; 63 - int capacity; 64 - }; 65 - 66 - /* Forward declaration */ 67 - struct abx500_fg; 68 - 69 - /** 70 - * struct abx500_fg_parameters - Fuel gauge algorithm parameters, in seconds 71 - * if not specified 72 - * @recovery_sleep_timer: Time between measurements while recovering 73 - * @recovery_total_time: Total recovery time 74 - * @init_timer: Measurement interval during startup 75 - * @init_discard_time: Time we discard voltage measurement at startup 76 - * @init_total_time: Total init time during startup 77 - * @high_curr_time: Time current has to be high to go to recovery 78 - * @accu_charging: FG accumulation time while charging 79 - * @accu_high_curr: FG accumulation time in high current mode 80 - * @high_curr_threshold: High current threshold, in mA 81 - * @lowbat_threshold: Low battery threshold, in mV 82 - * @overbat_threshold: Over battery threshold, in mV 83 - * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 84 - * Resolution in 50 mV step. 85 - * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 86 - * Resolution in 50 mV step. 87 - * @user_cap_limit Capacity reported from user must be within this 88 - * limit to be considered as sane, in percentage 89 - * points. 90 - * @maint_thres This is the threshold where we stop reporting 91 - * battery full while in maintenance, in per cent 92 - * @pcut_enable: Enable power cut feature in ab8505 93 - * @pcut_max_time: Max time threshold 94 - * @pcut_flag_time: Flagtime threshold 95 - * @pcut_max_restart: Max number of restarts 96 - * @pcut_debounce_time: Sets battery debounce time 97 - */ 98 - struct abx500_fg_parameters { 99 - int recovery_sleep_timer; 100 - int recovery_total_time; 101 - int init_timer; 102 - int init_discard_time; 103 - int init_total_time; 104 - int high_curr_time; 105 - int accu_charging; 106 - int accu_high_curr; 107 - int high_curr_threshold; 108 - int lowbat_threshold; 109 - int overbat_threshold; 110 - int battok_falling_th_sel0; 111 - int battok_raising_th_sel1; 112 - int user_cap_limit; 113 - int maint_thres; 114 - bool pcut_enable; 115 - u8 pcut_max_time; 116 - u8 pcut_flag_time; 117 - u8 pcut_max_restart; 118 - u8 pcut_debounce_time; 119 - }; 120 - 121 - /** 122 - * struct abx500_charger_maximization - struct used by the board config. 123 - * @use_maxi: Enable maximization for this battery type 124 - * @maxi_chg_curr: Maximum charger current allowed 125 - * @maxi_wait_cycles: cycles to wait before setting charger current 126 - * @charger_curr_step delta between two charger current settings (mA) 127 - */ 128 - struct abx500_maxim_parameters { 129 - bool ena_maxi; 130 - int chg_curr; 131 - int wait_cycles; 132 - int charger_curr_step; 133 - }; 134 - 135 - /** 136 - * struct abx500_battery_type - different batteries supported 137 - * @name: battery technology 138 - * @resis_high: battery upper resistance limit 139 - * @resis_low: battery lower resistance limit 140 - * @charge_full_design: Maximum battery capacity in mAh 141 - * @nominal_voltage: Nominal voltage of the battery in mV 142 - * @termination_vol: max voltage upto which battery can be charged 143 - * @termination_curr battery charging termination current in mA 144 - * @recharge_cap battery capacity limit that will trigger a new 145 - * full charging cycle in the case where maintenan- 146 - * -ce charging has been disabled 147 - * @normal_cur_lvl: charger current in normal state in mA 148 - * @normal_vol_lvl: charger voltage in normal state in mV 149 - * @maint_a_cur_lvl: charger current in maintenance A state in mA 150 - * @maint_a_vol_lvl: charger voltage in maintenance A state in mV 151 - * @maint_a_chg_timer_h: charge time in maintenance A state 152 - * @maint_b_cur_lvl: charger current in maintenance B state in mA 153 - * @maint_b_vol_lvl: charger voltage in maintenance B state in mV 154 - * @maint_b_chg_timer_h: charge time in maintenance B state 155 - * @low_high_cur_lvl: charger current in temp low/high state in mA 156 - * @low_high_vol_lvl: charger voltage in temp low/high state in mV' 157 - * @battery_resistance: battery inner resistance in mOhm. 158 - * @n_r_t_tbl_elements: number of elements in r_to_t_tbl 159 - * @r_to_t_tbl: table containing resistance to temp points 160 - * @n_v_cap_tbl_elements: number of elements in v_to_cap_tbl 161 - * @v_to_cap_tbl: Voltage to capacity (in %) table 162 - * @n_batres_tbl_elements number of elements in the batres_tbl 163 - * @batres_tbl battery internal resistance vs temperature table 164 - */ 165 - struct abx500_battery_type { 166 - int name; 167 - int resis_high; 168 - int resis_low; 169 - int charge_full_design; 170 - int nominal_voltage; 171 - int termination_vol; 172 - int termination_curr; 173 - int recharge_cap; 174 - int normal_cur_lvl; 175 - int normal_vol_lvl; 176 - int maint_a_cur_lvl; 177 - int maint_a_vol_lvl; 178 - int maint_a_chg_timer_h; 179 - int maint_b_cur_lvl; 180 - int maint_b_vol_lvl; 181 - int maint_b_chg_timer_h; 182 - int low_high_cur_lvl; 183 - int low_high_vol_lvl; 184 - int battery_resistance; 185 - int n_temp_tbl_elements; 186 - const struct abx500_res_to_temp *r_to_t_tbl; 187 - int n_v_cap_tbl_elements; 188 - const struct abx500_v_to_cap *v_to_cap_tbl; 189 - int n_batres_tbl_elements; 190 - const struct batres_vs_temp *batres_tbl; 191 - }; 192 - 193 - /** 194 - * struct abx500_bm_capacity_levels - abx500 capacity level data 195 - * @critical: critical capacity level in percent 196 - * @low: low capacity level in percent 197 - * @normal: normal capacity level in percent 198 - * @high: high capacity level in percent 199 - * @full: full capacity level in percent 200 - */ 201 - struct abx500_bm_capacity_levels { 202 - int critical; 203 - int low; 204 - int normal; 205 - int high; 206 - int full; 207 - }; 208 - 209 - /** 210 - * struct abx500_bm_charger_parameters - Charger specific parameters 211 - * @usb_volt_max: maximum allowed USB charger voltage in mV 212 - * @usb_curr_max: maximum allowed USB charger current in mA 213 - * @ac_volt_max: maximum allowed AC charger voltage in mV 214 - * @ac_curr_max: maximum allowed AC charger current in mA 215 - */ 216 - struct abx500_bm_charger_parameters { 217 - int usb_volt_max; 218 - int usb_curr_max; 219 - int ac_volt_max; 220 - int ac_curr_max; 221 - }; 222 - 223 - /** 224 - * struct abx500_bm_data - abx500 battery management data 225 - * @temp_under under this temp, charging is stopped 226 - * @temp_low between this temp and temp_under charging is reduced 227 - * @temp_high between this temp and temp_over charging is reduced 228 - * @temp_over over this temp, charging is stopped 229 - * @temp_now present battery temperature 230 - * @temp_interval_chg temperature measurement interval in s when charging 231 - * @temp_interval_nochg temperature measurement interval in s when not charging 232 - * @main_safety_tmr_h safety timer for main charger 233 - * @usb_safety_tmr_h safety timer for usb charger 234 - * @bkup_bat_v voltage which we charge the backup battery with 235 - * @bkup_bat_i current which we charge the backup battery with 236 - * @no_maintenance indicates that maintenance charging is disabled 237 - * @capacity_scaling indicates whether capacity scaling is to be used 238 - * @abx500_adc_therm placement of thermistor, batctrl or battemp adc 239 - * @chg_unknown_bat flag to enable charging of unknown batteries 240 - * @enable_overshoot flag to enable VBAT overshoot control 241 - * @auto_trig flag to enable auto adc trigger 242 - * @fg_res resistance of FG resistor in 0.1mOhm 243 - * @n_btypes number of elements in array bat_type 244 - * @batt_id index of the identified battery in array bat_type 245 - * @interval_charging charge alg cycle period time when charging (sec) 246 - * @interval_not_charging charge alg cycle period time when not charging (sec) 247 - * @temp_hysteresis temperature hysteresis 248 - * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) 249 - * @n_chg_out_curr number of elements in array chg_output_curr 250 - * @n_chg_in_curr number of elements in array chg_input_curr 251 - * @chg_output_curr charger output current level map 252 - * @chg_input_curr charger input current level map 253 - * @maxi maximization parameters 254 - * @cap_levels capacity in percent for the different capacity levels 255 - * @bat_type table of supported battery types 256 - * @chg_params charger parameters 257 - * @fg_params fuel gauge parameters 258 - */ 259 - struct abx500_bm_data { 260 - int temp_under; 261 - int temp_low; 262 - int temp_high; 263 - int temp_over; 264 - int temp_now; 265 - int temp_interval_chg; 266 - int temp_interval_nochg; 267 - int main_safety_tmr_h; 268 - int usb_safety_tmr_h; 269 - int bkup_bat_v; 270 - int bkup_bat_i; 271 - bool autopower_cfg; 272 - bool ac_enabled; 273 - bool usb_enabled; 274 - bool no_maintenance; 275 - bool capacity_scaling; 276 - bool chg_unknown_bat; 277 - bool enable_overshoot; 278 - bool auto_trig; 279 - enum abx500_adc_therm adc_therm; 280 - int fg_res; 281 - int n_btypes; 282 - int batt_id; 283 - int interval_charging; 284 - int interval_not_charging; 285 - int temp_hysteresis; 286 - int gnd_lift_resistance; 287 - int n_chg_out_curr; 288 - int n_chg_in_curr; 289 - int *chg_output_curr; 290 - int *chg_input_curr; 291 - const struct abx500_maxim_parameters *maxi; 292 - const struct abx500_bm_capacity_levels *cap_levels; 293 - struct abx500_battery_type *bat_type; 294 - const struct abx500_bm_charger_parameters *chg_params; 295 - const struct abx500_fg_parameters *fg_params; 296 - }; 297 - 298 - enum { 299 - NTC_EXTERNAL = 0, 300 - NTC_INTERNAL, 301 - }; 302 - 303 - int ab8500_bm_of_probe(struct device *dev, 304 - struct device_node *np, 305 - struct abx500_bm_data *bm); 306 - 307 31 int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg, 308 32 u8 value); 309 33 int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg,
-476
include/linux/mfd/abx500/ab8500-bm.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Copyright ST-Ericsson 2012. 4 - * 5 - * Author: Arun Murthy <arun.murthy@stericsson.com> 6 - */ 7 - 8 - #ifndef _AB8500_BM_H 9 - #define _AB8500_BM_H 10 - 11 - #include <linux/kernel.h> 12 - #include <linux/mfd/abx500.h> 13 - 14 - /* 15 - * System control 2 register offsets. 16 - * bank = 0x02 17 - */ 18 - #define AB8500_MAIN_WDOG_CTRL_REG 0x01 19 - #define AB8500_LOW_BAT_REG 0x03 20 - #define AB8500_BATT_OK_REG 0x04 21 - /* 22 - * USB/ULPI register offsets 23 - * Bank : 0x5 24 - */ 25 - #define AB8500_USB_LINE_STAT_REG 0x80 26 - #define AB8500_USB_LINE_CTRL2_REG 0x82 27 - #define AB8500_USB_LINK1_STAT_REG 0x94 28 - 29 - /* 30 - * Charger / status register offfsets 31 - * Bank : 0x0B 32 - */ 33 - #define AB8500_CH_STATUS1_REG 0x00 34 - #define AB8500_CH_STATUS2_REG 0x01 35 - #define AB8500_CH_USBCH_STAT1_REG 0x02 36 - #define AB8500_CH_USBCH_STAT2_REG 0x03 37 - #define AB8540_CH_USBCH_STAT3_REG 0x04 38 - #define AB8500_CH_STAT_REG 0x05 39 - 40 - /* 41 - * Charger / control register offfsets 42 - * Bank : 0x0B 43 - */ 44 - #define AB8500_CH_VOLT_LVL_REG 0x40 45 - #define AB8500_CH_VOLT_LVL_MAX_REG 0x41 /*Only in Cut2.0*/ 46 - #define AB8500_CH_OPT_CRNTLVL_REG 0x42 47 - #define AB8500_CH_OPT_CRNTLVL_MAX_REG 0x43 /*Only in Cut2.0*/ 48 - #define AB8500_CH_WD_TIMER_REG 0x50 49 - #define AB8500_CHARG_WD_CTRL 0x51 50 - #define AB8500_BTEMP_HIGH_TH 0x52 51 - #define AB8500_LED_INDICATOR_PWM_CTRL 0x53 52 - #define AB8500_LED_INDICATOR_PWM_DUTY 0x54 53 - #define AB8500_BATT_OVV 0x55 54 - #define AB8500_CHARGER_CTRL 0x56 55 - #define AB8500_BAT_CTRL_CURRENT_SOURCE 0x60 /*Only in Cut2.0*/ 56 - 57 - /* 58 - * Charger / main control register offsets 59 - * Bank : 0x0B 60 - */ 61 - #define AB8500_MCH_CTRL1 0x80 62 - #define AB8500_MCH_CTRL2 0x81 63 - #define AB8500_MCH_IPT_CURLVL_REG 0x82 64 - #define AB8500_CH_WD_REG 0x83 65 - 66 - /* 67 - * Charger / USB control register offsets 68 - * Bank : 0x0B 69 - */ 70 - #define AB8500_USBCH_CTRL1_REG 0xC0 71 - #define AB8500_USBCH_CTRL2_REG 0xC1 72 - #define AB8500_USBCH_IPT_CRNTLVL_REG 0xC2 73 - #define AB8540_USB_PP_MODE_REG 0xC5 74 - #define AB8540_USB_PP_CHR_REG 0xC6 75 - 76 - /* 77 - * Gas Gauge register offsets 78 - * Bank : 0x0C 79 - */ 80 - #define AB8500_GASG_CC_CTRL_REG 0x00 81 - #define AB8500_GASG_CC_ACCU1_REG 0x01 82 - #define AB8500_GASG_CC_ACCU2_REG 0x02 83 - #define AB8500_GASG_CC_ACCU3_REG 0x03 84 - #define AB8500_GASG_CC_ACCU4_REG 0x04 85 - #define AB8500_GASG_CC_SMPL_CNTRL_REG 0x05 86 - #define AB8500_GASG_CC_SMPL_CNTRH_REG 0x06 87 - #define AB8500_GASG_CC_SMPL_CNVL_REG 0x07 88 - #define AB8500_GASG_CC_SMPL_CNVH_REG 0x08 89 - #define AB8500_GASG_CC_CNTR_AVGOFF_REG 0x09 90 - #define AB8500_GASG_CC_OFFSET_REG 0x0A 91 - #define AB8500_GASG_CC_NCOV_ACCU 0x10 92 - #define AB8500_GASG_CC_NCOV_ACCU_CTRL 0x11 93 - #define AB8500_GASG_CC_NCOV_ACCU_LOW 0x12 94 - #define AB8500_GASG_CC_NCOV_ACCU_MED 0x13 95 - #define AB8500_GASG_CC_NCOV_ACCU_HIGH 0x14 96 - 97 - /* 98 - * Interrupt register offsets 99 - * Bank : 0x0E 100 - */ 101 - #define AB8500_IT_SOURCE2_REG 0x01 102 - #define AB8500_IT_SOURCE21_REG 0x14 103 - 104 - /* 105 - * RTC register offsets 106 - * Bank: 0x0F 107 - */ 108 - #define AB8500_RTC_BACKUP_CHG_REG 0x0C 109 - #define AB8500_RTC_CC_CONF_REG 0x01 110 - #define AB8500_RTC_CTRL_REG 0x0B 111 - #define AB8500_RTC_CTRL1_REG 0x11 112 - 113 - /* 114 - * OTP register offsets 115 - * Bank : 0x15 116 - */ 117 - #define AB8500_OTP_CONF_15 0x0E 118 - 119 - /* GPADC constants from AB8500 spec, UM0836 */ 120 - #define ADC_RESOLUTION 1024 121 - #define ADC_CH_MAIN_MIN 0 122 - #define ADC_CH_MAIN_MAX 20030 123 - #define ADC_CH_VBUS_MIN 0 124 - #define ADC_CH_VBUS_MAX 20030 125 - #define ADC_CH_VBAT_MIN 2300 126 - #define ADC_CH_VBAT_MAX 4800 127 - #define ADC_CH_BKBAT_MIN 0 128 - #define ADC_CH_BKBAT_MAX 3200 129 - 130 - /* Main charge i/p current */ 131 - #define MAIN_CH_IP_CUR_0P9A 0x80 132 - #define MAIN_CH_IP_CUR_1P0A 0x90 133 - #define MAIN_CH_IP_CUR_1P1A 0xA0 134 - #define MAIN_CH_IP_CUR_1P2A 0xB0 135 - #define MAIN_CH_IP_CUR_1P3A 0xC0 136 - #define MAIN_CH_IP_CUR_1P4A 0xD0 137 - #define MAIN_CH_IP_CUR_1P5A 0xE0 138 - 139 - /* ChVoltLevel */ 140 - #define CH_VOL_LVL_3P5 0x00 141 - #define CH_VOL_LVL_4P0 0x14 142 - #define CH_VOL_LVL_4P05 0x16 143 - #define CH_VOL_LVL_4P1 0x1B 144 - #define CH_VOL_LVL_4P15 0x20 145 - #define CH_VOL_LVL_4P2 0x25 146 - #define CH_VOL_LVL_4P6 0x4D 147 - 148 - /* ChOutputCurrentLevel */ 149 - #define CH_OP_CUR_LVL_0P1 0x00 150 - #define CH_OP_CUR_LVL_0P2 0x01 151 - #define CH_OP_CUR_LVL_0P3 0x02 152 - #define CH_OP_CUR_LVL_0P4 0x03 153 - #define CH_OP_CUR_LVL_0P5 0x04 154 - #define CH_OP_CUR_LVL_0P6 0x05 155 - #define CH_OP_CUR_LVL_0P7 0x06 156 - #define CH_OP_CUR_LVL_0P8 0x07 157 - #define CH_OP_CUR_LVL_0P9 0x08 158 - #define CH_OP_CUR_LVL_1P4 0x0D 159 - #define CH_OP_CUR_LVL_1P5 0x0E 160 - #define CH_OP_CUR_LVL_1P6 0x0F 161 - #define CH_OP_CUR_LVL_2P 0x3F 162 - 163 - /* BTEMP High thermal limits */ 164 - #define BTEMP_HIGH_TH_57_0 0x00 165 - #define BTEMP_HIGH_TH_52 0x01 166 - #define BTEMP_HIGH_TH_57_1 0x02 167 - #define BTEMP_HIGH_TH_62 0x03 168 - 169 - /* current is mA */ 170 - #define USB_0P1A 100 171 - #define USB_0P2A 200 172 - #define USB_0P3A 300 173 - #define USB_0P4A 400 174 - #define USB_0P5A 500 175 - 176 - #define LOW_BAT_3P1V 0x20 177 - #define LOW_BAT_2P3V 0x00 178 - #define LOW_BAT_RESET 0x01 179 - #define LOW_BAT_ENABLE 0x01 180 - 181 - /* Backup battery constants */ 182 - #define BUP_ICH_SEL_50UA 0x00 183 - #define BUP_ICH_SEL_150UA 0x04 184 - #define BUP_ICH_SEL_300UA 0x08 185 - #define BUP_ICH_SEL_700UA 0x0C 186 - 187 - enum bup_vch_sel { 188 - BUP_VCH_SEL_2P5V, 189 - BUP_VCH_SEL_2P6V, 190 - BUP_VCH_SEL_2P8V, 191 - BUP_VCH_SEL_3P1V, 192 - /* 193 - * Note that the following 5 values 2.7v, 2.9v, 3.0v, 3.2v, 3.3v 194 - * are only available on ab8540. You can't choose these 5 195 - * voltage on ab8500/ab8505/ab9540. 196 - */ 197 - BUP_VCH_SEL_2P7V, 198 - BUP_VCH_SEL_2P9V, 199 - BUP_VCH_SEL_3P0V, 200 - BUP_VCH_SEL_3P2V, 201 - BUP_VCH_SEL_3P3V, 202 - }; 203 - 204 - #define BUP_VCH_RANGE 0x02 205 - #define VBUP33_VRTCN 0x01 206 - 207 - /* Battery OVV constants */ 208 - #define BATT_OVV_ENA 0x02 209 - #define BATT_OVV_TH_3P7 0x00 210 - #define BATT_OVV_TH_4P75 0x01 211 - 212 - /* A value to indicate over voltage */ 213 - #define BATT_OVV_VALUE 4750 214 - 215 - /* VBUS OVV constants */ 216 - #define VBUS_OVV_SELECT_MASK 0x78 217 - #define VBUS_OVV_SELECT_5P6V 0x00 218 - #define VBUS_OVV_SELECT_5P7V 0x08 219 - #define VBUS_OVV_SELECT_5P8V 0x10 220 - #define VBUS_OVV_SELECT_5P9V 0x18 221 - #define VBUS_OVV_SELECT_6P0V 0x20 222 - #define VBUS_OVV_SELECT_6P1V 0x28 223 - #define VBUS_OVV_SELECT_6P2V 0x30 224 - #define VBUS_OVV_SELECT_6P3V 0x38 225 - 226 - #define VBUS_AUTO_IN_CURR_LIM_ENA 0x04 227 - 228 - /* Fuel Gauge constants */ 229 - #define RESET_ACCU 0x02 230 - #define READ_REQ 0x01 231 - #define CC_DEEP_SLEEP_ENA 0x02 232 - #define CC_PWR_UP_ENA 0x01 233 - #define CC_SAMPLES_40 0x28 234 - #define RD_NCONV_ACCU_REQ 0x01 235 - #define CC_CALIB 0x08 236 - #define CC_INTAVGOFFSET_ENA 0x10 237 - #define CC_MUXOFFSET 0x80 238 - #define CC_INT_CAL_N_AVG_MASK 0x60 239 - #define CC_INT_CAL_SAMPLES_16 0x40 240 - #define CC_INT_CAL_SAMPLES_8 0x20 241 - #define CC_INT_CAL_SAMPLES_4 0x00 242 - 243 - /* RTC constants */ 244 - #define RTC_BUP_CH_ENA 0x10 245 - 246 - /* BatCtrl Current Source Constants */ 247 - #define BAT_CTRL_7U_ENA 0x01 248 - #define BAT_CTRL_20U_ENA 0x02 249 - #define BAT_CTRL_18U_ENA 0x01 250 - #define BAT_CTRL_16U_ENA 0x02 251 - #define BAT_CTRL_CMP_ENA 0x04 252 - #define FORCE_BAT_CTRL_CMP_HIGH 0x08 253 - #define BAT_CTRL_PULL_UP_ENA 0x10 254 - 255 - /* Battery type */ 256 - #define BATTERY_UNKNOWN 00 257 - 258 - /* Registers for pcut feature in ab8505 and ab9540 */ 259 - #define AB8505_RTC_PCUT_CTL_STATUS_REG 0x12 260 - #define AB8505_RTC_PCUT_TIME_REG 0x13 261 - #define AB8505_RTC_PCUT_MAX_TIME_REG 0x14 262 - #define AB8505_RTC_PCUT_FLAG_TIME_REG 0x15 263 - #define AB8505_RTC_PCUT_RESTART_REG 0x16 264 - #define AB8505_RTC_PCUT_DEBOUNCE_REG 0x17 265 - 266 - /* USB Power Path constants for ab8540 */ 267 - #define BUS_VSYS_VOL_SELECT_MASK 0x06 268 - #define BUS_VSYS_VOL_SELECT_3P6V 0x00 269 - #define BUS_VSYS_VOL_SELECT_3P325V 0x02 270 - #define BUS_VSYS_VOL_SELECT_3P9V 0x04 271 - #define BUS_VSYS_VOL_SELECT_4P3V 0x06 272 - #define BUS_POWER_PATH_MODE_ENA 0x01 273 - #define BUS_PP_PRECHG_CURRENT_MASK 0x0E 274 - #define BUS_POWER_PATH_PRECHG_ENA 0x01 275 - 276 - /** 277 - * struct res_to_temp - defines one point in a temp to res curve. To 278 - * be used in battery packs that combines the identification resistor with a 279 - * NTC resistor. 280 - * @temp: battery pack temperature in Celsius 281 - * @resist: NTC resistor net total resistance 282 - */ 283 - struct res_to_temp { 284 - int temp; 285 - int resist; 286 - }; 287 - 288 - /** 289 - * struct batres_vs_temp - defines one point in a temp vs battery internal 290 - * resistance curve. 291 - * @temp: battery pack temperature in Celsius 292 - * @resist: battery internal reistance in mOhm 293 - */ 294 - struct batres_vs_temp { 295 - int temp; 296 - int resist; 297 - }; 298 - 299 - /* Forward declaration */ 300 - struct ab8500_fg; 301 - 302 - /** 303 - * struct ab8500_fg_parameters - Fuel gauge algorithm parameters, in seconds 304 - * if not specified 305 - * @recovery_sleep_timer: Time between measurements while recovering 306 - * @recovery_total_time: Total recovery time 307 - * @init_timer: Measurement interval during startup 308 - * @init_discard_time: Time we discard voltage measurement at startup 309 - * @init_total_time: Total init time during startup 310 - * @high_curr_time: Time current has to be high to go to recovery 311 - * @accu_charging: FG accumulation time while charging 312 - * @accu_high_curr: FG accumulation time in high current mode 313 - * @high_curr_threshold: High current threshold, in mA 314 - * @lowbat_threshold: Low battery threshold, in mV 315 - * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 316 - * Resolution in 50 mV step. 317 - * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 318 - * Resolution in 50 mV step. 319 - * @user_cap_limit Capacity reported from user must be within this 320 - * limit to be considered as sane, in percentage 321 - * points. 322 - * @maint_thres This is the threshold where we stop reporting 323 - * battery full while in maintenance, in per cent 324 - * @pcut_enable: Enable power cut feature in ab8505 325 - * @pcut_max_time: Max time threshold 326 - * @pcut_flag_time: Flagtime threshold 327 - * @pcut_max_restart: Max number of restarts 328 - * @pcut_debunce_time: Sets battery debounce time 329 - */ 330 - struct ab8500_fg_parameters { 331 - int recovery_sleep_timer; 332 - int recovery_total_time; 333 - int init_timer; 334 - int init_discard_time; 335 - int init_total_time; 336 - int high_curr_time; 337 - int accu_charging; 338 - int accu_high_curr; 339 - int high_curr_threshold; 340 - int lowbat_threshold; 341 - int battok_falling_th_sel0; 342 - int battok_raising_th_sel1; 343 - int user_cap_limit; 344 - int maint_thres; 345 - bool pcut_enable; 346 - u8 pcut_max_time; 347 - u8 pcut_flag_time; 348 - u8 pcut_max_restart; 349 - u8 pcut_debunce_time; 350 - }; 351 - 352 - /** 353 - * struct ab8500_charger_maximization - struct used by the board config. 354 - * @use_maxi: Enable maximization for this battery type 355 - * @maxi_chg_curr: Maximum charger current allowed 356 - * @maxi_wait_cycles: cycles to wait before setting charger current 357 - * @charger_curr_step delta between two charger current settings (mA) 358 - */ 359 - struct ab8500_maxim_parameters { 360 - bool ena_maxi; 361 - int chg_curr; 362 - int wait_cycles; 363 - int charger_curr_step; 364 - }; 365 - 366 - /** 367 - * struct ab8500_bm_capacity_levels - ab8500 capacity level data 368 - * @critical: critical capacity level in percent 369 - * @low: low capacity level in percent 370 - * @normal: normal capacity level in percent 371 - * @high: high capacity level in percent 372 - * @full: full capacity level in percent 373 - */ 374 - struct ab8500_bm_capacity_levels { 375 - int critical; 376 - int low; 377 - int normal; 378 - int high; 379 - int full; 380 - }; 381 - 382 - /** 383 - * struct ab8500_bm_charger_parameters - Charger specific parameters 384 - * @usb_volt_max: maximum allowed USB charger voltage in mV 385 - * @usb_curr_max: maximum allowed USB charger current in mA 386 - * @ac_volt_max: maximum allowed AC charger voltage in mV 387 - * @ac_curr_max: maximum allowed AC charger current in mA 388 - */ 389 - struct ab8500_bm_charger_parameters { 390 - int usb_volt_max; 391 - int usb_curr_max; 392 - int ac_volt_max; 393 - int ac_curr_max; 394 - }; 395 - 396 - /** 397 - * struct ab8500_bm_data - ab8500 battery management data 398 - * @temp_under under this temp, charging is stopped 399 - * @temp_low between this temp and temp_under charging is reduced 400 - * @temp_high between this temp and temp_over charging is reduced 401 - * @temp_over over this temp, charging is stopped 402 - * @temp_interval_chg temperature measurement interval in s when charging 403 - * @temp_interval_nochg temperature measurement interval in s when not charging 404 - * @main_safety_tmr_h safety timer for main charger 405 - * @usb_safety_tmr_h safety timer for usb charger 406 - * @bkup_bat_v voltage which we charge the backup battery with 407 - * @bkup_bat_i current which we charge the backup battery with 408 - * @no_maintenance indicates that maintenance charging is disabled 409 - * @capacity_scaling indicates whether capacity scaling is to be used 410 - * @adc_therm placement of thermistor, batctrl or battemp adc 411 - * @chg_unknown_bat flag to enable charging of unknown batteries 412 - * @enable_overshoot flag to enable VBAT overshoot control 413 - * @fg_res resistance of FG resistor in 0.1mOhm 414 - * @n_btypes number of elements in array bat_type 415 - * @batt_id index of the identified battery in array bat_type 416 - * @interval_charging charge alg cycle period time when charging (sec) 417 - * @interval_not_charging charge alg cycle period time when not charging (sec) 418 - * @temp_hysteresis temperature hysteresis 419 - * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) 420 - * @maxi: maximization parameters 421 - * @cap_levels capacity in percent for the different capacity levels 422 - * @bat_type table of supported battery types 423 - * @chg_params charger parameters 424 - * @fg_params fuel gauge parameters 425 - */ 426 - struct ab8500_bm_data { 427 - int temp_under; 428 - int temp_low; 429 - int temp_high; 430 - int temp_over; 431 - int temp_interval_chg; 432 - int temp_interval_nochg; 433 - int main_safety_tmr_h; 434 - int usb_safety_tmr_h; 435 - int bkup_bat_v; 436 - int bkup_bat_i; 437 - bool no_maintenance; 438 - bool capacity_scaling; 439 - bool chg_unknown_bat; 440 - bool enable_overshoot; 441 - enum abx500_adc_therm adc_therm; 442 - int fg_res; 443 - int n_btypes; 444 - int batt_id; 445 - int interval_charging; 446 - int interval_not_charging; 447 - int temp_hysteresis; 448 - int gnd_lift_resistance; 449 - const struct ab8500_maxim_parameters *maxi; 450 - const struct ab8500_bm_capacity_levels *cap_levels; 451 - const struct ab8500_bm_charger_parameters *chg_params; 452 - const struct ab8500_fg_parameters *fg_params; 453 - }; 454 - 455 - struct ab8500_btemp; 456 - struct ab8500_gpadc; 457 - struct ab8500_fg; 458 - 459 - #ifdef CONFIG_AB8500_BM 460 - extern struct abx500_bm_data ab8500_bm_data; 461 - 462 - void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); 463 - struct ab8500_btemp *ab8500_btemp_get(void); 464 - int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp); 465 - int ab8500_btemp_get_temp(struct ab8500_btemp *btemp); 466 - struct ab8500_fg *ab8500_fg_get(void); 467 - int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev); 468 - int ab8500_fg_inst_curr_start(struct ab8500_fg *di); 469 - int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res); 470 - int ab8500_fg_inst_curr_started(struct ab8500_fg *di); 471 - int ab8500_fg_inst_curr_done(struct ab8500_fg *di); 472 - 473 - #else 474 - static struct abx500_bm_data ab8500_bm_data; 475 - #endif 476 - #endif /* _AB8500_BM_H */
-51
include/linux/mfd/abx500/ux500_chargalg.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Copyright (C) ST-Ericsson SA 2012 4 - * Author: Johan Gardsmark <johan.gardsmark@stericsson.com> for ST-Ericsson. 5 - */ 6 - 7 - #ifndef _UX500_CHARGALG_H 8 - #define _UX500_CHARGALG_H 9 - 10 - #include <linux/power_supply.h> 11 - 12 - /* 13 - * Valid only for supplies of type: 14 - * - POWER_SUPPLY_TYPE_MAINS, 15 - * - POWER_SUPPLY_TYPE_USB, 16 - * because only them store as drv_data pointer to struct ux500_charger. 17 - */ 18 - #define psy_to_ux500_charger(x) power_supply_get_drvdata(psy) 19 - 20 - /* Forward declaration */ 21 - struct ux500_charger; 22 - 23 - struct ux500_charger_ops { 24 - int (*enable) (struct ux500_charger *, int, int, int); 25 - int (*check_enable) (struct ux500_charger *, int, int); 26 - int (*kick_wd) (struct ux500_charger *); 27 - int (*update_curr) (struct ux500_charger *, int); 28 - }; 29 - 30 - /** 31 - * struct ux500_charger - power supply ux500 charger sub class 32 - * @psy power supply base class 33 - * @ops ux500 charger operations 34 - * @max_out_volt maximum output charger voltage in mV 35 - * @max_out_curr maximum output charger current in mA 36 - * @enabled indicates if this charger is used or not 37 - * @external external charger unit (pm2xxx) 38 - */ 39 - struct ux500_charger { 40 - struct power_supply *psy; 41 - struct ux500_charger_ops ops; 42 - int max_out_volt; 43 - int max_out_curr; 44 - int wdt_refresh; 45 - bool enabled; 46 - bool external; 47 - }; 48 - 49 - extern struct blocking_notifier_head charger_notifier_list; 50 - 51 - #endif
+1 -1
include/linux/power/bq27xxx_battery.h
··· 33 33 BQ27Z561, 34 34 BQ28Z610, 35 35 BQ34Z100, 36 + BQ78Z100, 36 37 }; 37 38 38 39 struct bq27xxx_device_info; ··· 54 53 int capacity; 55 54 int energy; 56 55 int flags; 57 - int power_avg; 58 56 int health; 59 57 }; 60 58
+10 -4
include/linux/power_supply.h
··· 381 381 extern struct atomic_notifier_head power_supply_notifier; 382 382 extern int power_supply_reg_notifier(struct notifier_block *nb); 383 383 extern void power_supply_unreg_notifier(struct notifier_block *nb); 384 + #if IS_ENABLED(CONFIG_POWER_SUPPLY) 384 385 extern struct power_supply *power_supply_get_by_name(const char *name); 385 386 extern void power_supply_put(struct power_supply *psy); 387 + #else 388 + static inline void power_supply_put(struct power_supply *psy) {} 389 + static inline struct power_supply *power_supply_get_by_name(const char *name) 390 + { return NULL; } 391 + #endif 386 392 #ifdef CONFIG_OF 387 393 extern struct power_supply *power_supply_get_by_phandle(struct device_node *np, 388 394 const char *property); ··· 489 483 case POWER_SUPPLY_PROP_CURRENT_NOW: 490 484 case POWER_SUPPLY_PROP_CURRENT_AVG: 491 485 case POWER_SUPPLY_PROP_CURRENT_BOOT: 492 - return 1; 486 + return true; 493 487 default: 494 488 break; 495 489 } 496 490 497 - return 0; 491 + return false; 498 492 } 499 493 500 494 static inline bool power_supply_is_watt_property(enum power_supply_property psp) ··· 517 511 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: 518 512 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: 519 513 case POWER_SUPPLY_PROP_POWER_NOW: 520 - return 1; 514 + return true; 521 515 default: 522 516 break; 523 517 } 524 518 525 - return 0; 519 + return false; 526 520 } 527 521 528 522 #ifdef CONFIG_POWER_SUPPLY_HWMON