Commit 0df24138 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull power supply and reset updates from Sebastian Reichel:

 - Add new Qualcomm PMI8998/PM660 SMB2 charger

 - bq256xx: support systems without thermistors

 - cros_pchg: fix peripheral device status after system resume

 - axp20x_usb_power: add support for AXP192

 - qcom-pon: add support for pm8941

 - at91-reset: prepare to expose reset reason to sysfs

 - switch all I2C drivers back to use .probe instead of .probe_new

 - convert some more DT bindings to YAML

 - misc cleanups

* tag 'for-v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (28 commits)
  MAINTAINERS: add documentation file for Microchip SAMA5D2 shutdown controller
  dt-bindings: power: reset: atmel,sama5d2-shdwc: convert to yaml
  dt-bindings: power: reset: atmel,at91sam9260-shdwc: convert to yaml
  power: reset: at91-reset: change the power on reason prototype
  power: reset: qcom-pon: add support for pm8941-pon
  dt-bindings: power: reset: qcom-pon: define pm8941-pon
  power: supply: add Qualcomm PMI8998 SMB2 Charger driver
  dt-bindings: power: supply: qcom,pmi8998-charger: add bindings for smb2 driver
  power: supply: rt9467: Make charger-enable control as logic level
  power: supply: Switch i2c drivers back to use .probe()
  power: reset: add HAS_IOPORT dependencies
  dt-bindings: power: supply: axp20x: Add AXP192 compatible
  power: supply: axp20x_usb_power: Add support for AXP192
  power: supply: axp20x_usb_power: Remove variant IDs from VBUS polling check
  power: supply: axp20x_usb_power: Use regmap field for VBUS disabling
  power: supply: axp20x_usb_power: Use regmap fields for USB BC feature
  power: supply: axp20x_usb_power: Use regmap fields for VBUS monitor feature
  power: supply: axp20x_usb_power: Simplify USB current limit handling
  power: supply: hwmon: constify pointers to hwmon_channel_info
  power: supply: twl4030_madc_battery: Refactor twl4030_madc_bat_ext_changed()
  ...
parents 02676ecc ef8d95b4
...@@ -52,100 +52,6 @@ Example: ...@@ -52,100 +52,6 @@ Example:
reg = <0xe3804000 0x1000>; reg = <0xe3804000 0x1000>;
}; };
SHDWC Shutdown Controller
required properties:
- compatible: Should be "atmel,<chip>-shdwc".
<chip> can be "at91sam9260", "at91sam9rl" or "at91sam9x5".
- reg: Should contain registers location and length
- clocks: phandle to input clock.
optional properties:
- atmel,wakeup-mode: String, operation mode of the wakeup mode.
Supported values are: "none", "high", "low", "any".
- atmel,wakeup-counter: Counter on Wake-up 0 (between 0x0 and 0xf).
optional at91sam9260 properties:
- atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up.
optional at91sam9rl properties:
- atmel,wakeup-rtc-timer: boolean to enable Real-time Clock Wake-up.
- atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up.
optional at91sam9x5 properties:
- atmel,wakeup-rtc-timer: boolean to enable Real-time Clock Wake-up.
Example:
shdwc@fffffd10 {
compatible = "atmel,at91sam9260-shdwc";
reg = <0xfffffd10 0x10>;
clocks = <&clk32k>;
};
SHDWC SAMA5D2-Compatible Shutdown Controller
1) shdwc node
required properties:
- compatible: should be "atmel,sama5d2-shdwc", "microchip,sam9x60-shdwc" or
"microchip,sama7g5-shdwc"
- reg: should contain registers location and length
- clocks: phandle to input clock.
- #address-cells: should be one. The cell is the wake-up input index.
- #size-cells: should be zero.
optional properties:
- debounce-delay-us: minimum wake-up inputs debouncer period in
microseconds. It's usually a board-related property.
- atmel,wakeup-rtc-timer: boolean to enable Real-Time Clock wake-up.
optional microchip,sam9x60-shdwc or microchip,sama7g5-shdwc properties:
- atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up.
The node contains child nodes for each wake-up input that the platform uses.
2) input nodes
Wake-up input nodes are usually described in the "board" part of the Device
Tree. Note also that input 0 is linked to the wake-up pin and is frequently
used.
Required properties:
- reg: should contain the wake-up input index [0 - 15].
Optional properties:
- atmel,wakeup-active-high: boolean, the corresponding wake-up input described
by the child, forces the wake-up of the core power supply on a high level.
The default is to be active low.
Example:
On the SoC side:
shdwc@f8048010 {
compatible = "atmel,sama5d2-shdwc";
reg = <0xf8048010 0x10>;
clocks = <&clk32k>;
#address-cells = <1>;
#size-cells = <0>;
atmel,wakeup-rtc-timer;
};
On the board side:
shdwc@f8048010 {
debounce-delay-us = <976>;
input@0 {
reg = <0>;
};
input@1 {
reg = <1>;
atmel,wakeup-active-high;
};
};
Special Function Registers (SFR) Special Function Registers (SFR)
Special Function Registers (SFR) manage specific aspects of the integrated Special Function Registers (SFR) manage specific aspects of the integrated
......
...@@ -134,6 +134,7 @@ patternProperties: ...@@ -134,6 +134,7 @@ patternProperties:
oneOf: oneOf:
- $ref: /schemas/power/supply/qcom,pm8941-charger.yaml# - $ref: /schemas/power/supply/qcom,pm8941-charger.yaml#
- $ref: /schemas/power/supply/qcom,pm8941-coincell.yaml# - $ref: /schemas/power/supply/qcom,pm8941-coincell.yaml#
- $ref: /schemas/power/supply/qcom,pmi8998-charger.yaml#
"gpio@[0-9a-f]+$": "gpio@[0-9a-f]+$":
type: object type: object
......
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/power/reset/atmel,at91sam9260-shdwc.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Microchip AT91 SHDWC Shutdown Controller
maintainers:
- Claudiu Beznea <claudiu.beznea@microchip.com>
description: |
Microchip AT91 SHDWC shutdown controller controls the power supplies VDDIO
and VDDCORE and the wake-up detection on debounced input lines.
properties:
compatible:
enum:
- atmel,at91sam9260-shdwc
- atmel,at91sam9rl-shdwc
- atmel,at91sam9x5-shdwc
reg:
maxItems: 1
clocks:
maxItems: 1
atmel,wakeup-mode:
description: operation mode of the wakeup mode
$ref: /schemas/types.yaml#/definitions/string
enum: [ none, high, low, any ]
atmel,wakeup-counter:
description: counter on wake-up 0
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 0
maximum: 15
atmel,wakeup-rtt-timer:
description: enable real-time timer wake-up
type: boolean
atmel,wakeup-rtc-timer:
description: enable real-time clock wake-up
type: boolean
required:
- compatible
- reg
- clocks
allOf:
- if:
properties:
compatible:
contains:
const: atmel,at91sam9x5-shdwc
then:
properties:
atmel,wakeup-rtt-timer: false
- if:
properties:
compatible:
contains:
const: atmel,at91sam9260-shdwc
then:
properties:
atmel,wakeup-rtc-timer: false
additionalProperties: false
examples:
- |
shdwc: poweroff@fffffd10 {
compatible = "atmel,at91sam9260-shdwc";
reg = <0xfffffd10 0x10>;
clocks = <&clk32k>;
};
...
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/power/reset/atmel,sama5d2-shdwc.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Microchip AT91 SAMA5D2 SHDWC Shutdown Controller
maintainers:
- Claudiu Beznea <claudiu.beznea@microchip.com>
description: |
Microchip AT91 SHDWC shutdown controller controls the power supplies VDDIO
and VDDCORE and the wake-up detection on debounced input lines.
properties:
compatible:
oneOf:
- items:
- const: microchip,sama7g5-shdwc
- const: syscon
- enum:
- atmel,sama5d2-shdwc
- microchip,sam9x60-shdwc
reg:
maxItems: 1
clocks:
maxItems: 1
"#address-cells":
const: 1
"#size-cells":
const: 0
debounce-delay-us:
description:
Minimum wake-up inputs debouncer period in microseconds. It is usually a
board-related property.
atmel,wakeup-rtc-timer:
description: enable real-time clock wake-up
type: boolean
atmel,wakeup-rtt-timer:
description: enable real-time timer wake-up
type: boolean
patternProperties:
"^input@[0-15]$":
description:
Wake-up input nodes. These are usually described in the "board" part of
the Device Tree. Note also that input 0 is linked to the wake-up pin and
is frequently used.
type: object
properties:
reg:
description: contains the wake-up input index
minimum: 0
maximum: 15
atmel,wakeup-active-high:
description:
The corresponding wake-up input described by the child forces the
wake-up of the core power supply on a high level. The default is to
be active low.
type: boolean
required:
- reg
additionalProperties: false
required:
- compatible
- reg
- clocks
allOf:
- if:
properties:
compatible:
contains:
const: atmel,sama5d2-shdwc
then:
properties:
atmel,wakeup-rtt-timer: false
additionalProperties: false
examples:
- |
shdwc: poweroff@f8048010 {
compatible = "atmel,sama5d2-shdwc";
reg = <0xf8048010 0x10>;
clocks = <&clk32k>;
#address-cells = <1>;
#size-cells = <0>;
atmel,wakeup-rtc-timer;
debounce-delay-us = <976>;
input@0 {
reg = <0>;
};
input@1 {
reg = <1>;
atmel,wakeup-active-high;
};
};
...
NVMEM reboot mode driver
This driver gets reboot mode magic value from reboot-mode driver
and stores it in a NVMEM cell named "reboot-mode". Then the bootloader
can read it and take different action according to the magic
value stored.
Required properties:
- compatible: should be "nvmem-reboot-mode".
- nvmem-cells: A phandle to the reboot mode provided by a nvmem device.
- nvmem-cell-names: Should be "reboot-mode".
The rest of the properties should follow the generic reboot-mode description
found in reboot-mode.txt
Example:
reboot-mode {
compatible = "nvmem-reboot-mode";
nvmem-cells = <&reboot_mode>;
nvmem-cell-names = "reboot-mode";
mode-normal = <0xAAAA5501>;
mode-bootloader = <0xBBBB5500>;
mode-recovery = <0xCCCC5502>;
mode-test = <0xDDDD5503>;
};
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/power/reset/nvmem-reboot-mode.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Generic NVMEM reboot mode
maintainers:
- Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
description:
This driver gets the reboot mode magic value from the reboot-mode driver
and stores it in the NVMEM cell named "reboot-mode". The bootloader can
then read it and take different action according to the value.
properties:
compatible:
const: nvmem-reboot-mode
nvmem-cells:
description:
A phandle pointing to the nvmem-cells node where the vendor-specific
magic value representing the reboot mode is stored.
maxItems: 1
nvmem-cell-names:
items:
- const: reboot-mode
patternProperties:
"^mode-.+":
$ref: /schemas/types.yaml#/definitions/uint32
description: Vendor-specific mode value written to the mode register
required:
- compatible
- nvmem-cells
- nvmem-cell-names
additionalProperties: false
examples:
- |
reboot-mode {
compatible = "nvmem-reboot-mode";
nvmem-cells = <&reboot_reason>;
nvmem-cell-names = "reboot-mode";
mode-recovery = <0x01>;
mode-bootloader = <0x02>;
};
...
...@@ -19,6 +19,7 @@ properties: ...@@ -19,6 +19,7 @@ properties:
compatible: compatible:
enum: enum:
- qcom,pm8916-pon - qcom,pm8916-pon
- qcom,pm8941-pon
- qcom,pms405-pon - qcom,pms405-pon
- qcom,pm8998-pon - qcom,pm8998-pon
- qcom,pmk8350-pon - qcom,pmk8350-pon
...@@ -56,7 +57,6 @@ required: ...@@ -56,7 +57,6 @@ required:
unevaluatedProperties: false unevaluatedProperties: false
allOf: allOf:
- $ref: reboot-mode.yaml#
- if: - if:
properties: properties:
compatible: compatible:
...@@ -65,6 +65,23 @@ allOf: ...@@ -65,6 +65,23 @@ allOf:
- qcom,pm8916-pon - qcom,pm8916-pon
- qcom,pms405-pon - qcom,pms405-pon
- qcom,pm8998-pon - qcom,pm8998-pon
then:
allOf:
- $ref: reboot-mode.yaml#
properties:
reg:
maxItems: 1
reg-names:
items:
- const: pon
# Special case for pm8941, which doesn't store reset mode
- if:
properties:
compatible:
contains:
const: qcom,pm8941-pon
then: then:
properties: properties:
reg: reg:
...@@ -72,6 +89,7 @@ allOf: ...@@ -72,6 +89,7 @@ allOf:
reg-names: reg-names:
items: items:
- const: pon - const: pon
- if: - if:
properties: properties:
compatible: compatible:
......
...@@ -68,11 +68,29 @@ properties: ...@@ -68,11 +68,29 @@ properties:
Interrupt sends an active low, 256 μs pulse to host to report the charger Interrupt sends an active low, 256 μs pulse to host to report the charger
device status and faults. device status and faults.
ti,no-thermistor:
type: boolean
description: Indicates that no thermistor is connected to the TS pin
required: required:
- compatible - compatible
- reg - reg
- monitored-battery - monitored-battery
allOf:
- if:
properties:
compatible:
contains:
enum:
- ti,bq25600
- ti,bq25601
- ti,bq25600d
- ti,bq25601d
then:
properties:
ti,no-thermistor: false
additionalProperties: false additionalProperties: false
examples: examples:
......
# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/power/supply/qcom,pmi8998-charger.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Qualcomm PMI8998/PM660 Switch-Mode Battery Charger "2"
maintainers:
- Caleb Connolly <caleb.connolly@linaro.org>
properties:
compatible:
enum:
- qcom,pmi8998-charger
- qcom,pm660-charger
reg:
maxItems: 1
interrupts:
maxItems: 4
interrupt-names:
items:
- const: usb-plugin
- const: bat-ov
- const: wdog-bark
- const: usbin-icl-change
io-channels:
items:
- description: USB in current in uA
- description: USB in voltage in uV
io-channel-names:
items:
- const: usbin_i
- const: usbin_v
monitored-battery:
description: phandle to the simple-battery node
$ref: /schemas/types.yaml#/definitions/phandle
required:
- compatible
- reg
- interrupts
- interrupt-names
- io-channels
- io-channel-names
- monitored-battery
additionalProperties: false
examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
pmic {
#address-cells = <1>;
#size-cells = <0>;
#interrupt-cells = <4>;
charger@1000 {
compatible = "qcom,pmi8998-charger";
reg = <0x1000>;
interrupts = <0x2 0x12 0x2 IRQ_TYPE_EDGE_BOTH>,
<0x2 0x13 0x4 IRQ_TYPE_EDGE_BOTH>,
<0x2 0x13 0x6 IRQ_TYPE_EDGE_RISING>,
<0x2 0x16 0x1 IRQ_TYPE_EDGE_RISING>;
interrupt-names = "usb-plugin", "bat-ov", "wdog-bark", "usbin-icl-change";
io-channels = <&pmi8998_rradc 3>,
<&pmi8998_rradc 4>;
io-channel-names = "usbin_i",
"usbin_v";
monitored-battery = <&battery>;
};
};
...@@ -22,6 +22,7 @@ properties: ...@@ -22,6 +22,7 @@ properties:
compatible: compatible:
oneOf: oneOf:
- enum: - enum:
- x-powers,axp192-usb-power-supply
- x-powers,axp202-usb-power-supply - x-powers,axp202-usb-power-supply
- x-powers,axp221-usb-power-supply - x-powers,axp221-usb-power-supply
- x-powers,axp223-usb-power-supply - x-powers,axp223-usb-power-supply
......
...@@ -14019,6 +14019,7 @@ F: include/dt-bindings/iio/adc/at91-sama5d2_adc.h ...@@ -14019,6 +14019,7 @@ F: include/dt-bindings/iio/adc/at91-sama5d2_adc.h
MICROCHIP SAMA5D2-COMPATIBLE SHUTDOWN CONTROLLER MICROCHIP SAMA5D2-COMPATIBLE SHUTDOWN CONTROLLER
M: Claudiu Beznea <claudiu.beznea@microchip.com> M: Claudiu Beznea <claudiu.beznea@microchip.com>
S: Supported S: Supported
F: Documentation/devicetree/bindings/power/reset/atmel,sama5d2-shdwc.yaml
F: drivers/power/reset/at91-sama5d2_shdwc.c F: drivers/power/reset/at91-sama5d2_shdwc.c
MICROCHIP SOC DRIVERS MICROCHIP SOC DRIVERS
......
...@@ -158,6 +158,7 @@ config POWER_RESET_OXNAS ...@@ -158,6 +158,7 @@ config POWER_RESET_OXNAS
config POWER_RESET_PIIX4_POWEROFF config POWER_RESET_PIIX4_POWEROFF
tristate "Intel PIIX4 power-off driver" tristate "Intel PIIX4 power-off driver"
depends on PCI depends on PCI
depends on HAS_IOPORT
depends on MIPS || COMPILE_TEST depends on MIPS || COMPILE_TEST
help help
This driver supports powering off a system using the Intel PIIX4 This driver supports powering off a system using the Intel PIIX4
......
...@@ -149,11 +149,10 @@ static int at91_reset(struct notifier_block *this, unsigned long mode, ...@@ -149,11 +149,10 @@ static int at91_reset(struct notifier_block *this, unsigned long mode,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
static void __init at91_reset_status(struct platform_device *pdev, static const char * __init at91_reset_reason(struct at91_reset *reset)
void __iomem *base)
{ {
u32 reg = readl(reset->rstc_base + AT91_RSTC_SR);
const char *reason; const char *reason;
u32 reg = readl(base + AT91_RSTC_SR);
switch ((reg & AT91_RSTC_RSTTYP) >> 8) { switch ((reg & AT91_RSTC_RSTTYP) >> 8) {
case RESET_TYPE_GENERAL: case RESET_TYPE_GENERAL:
...@@ -185,7 +184,7 @@ static void __init at91_reset_status(struct platform_device *pdev, ...@@ -185,7 +184,7 @@ static void __init at91_reset_status(struct platform_device *pdev,
break; break;
} }
dev_info(&pdev->dev, "Starting after %s\n", reason); return reason;
} }
static const struct of_device_id at91_ramc_of_match[] = { static const struct of_device_id at91_ramc_of_match[] = {
...@@ -392,7 +391,7 @@ static int __init at91_reset_probe(struct platform_device *pdev) ...@@ -392,7 +391,7 @@ static int __init at91_reset_probe(struct platform_device *pdev)
if (ret) if (ret)
goto disable_clk; goto disable_clk;
at91_reset_status(pdev, reset->rstc_base); dev_info(&pdev->dev, "Starting after %s\n", at91_reset_reason(reset));
return 0; return 0;
......
...@@ -105,7 +105,7 @@ static int gpio_restart_probe(struct platform_device *pdev) ...@@ -105,7 +105,7 @@ static int gpio_restart_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int gpio_restart_remove(struct platform_device *pdev) static void gpio_restart_remove(struct platform_device *pdev)
{ {
struct gpio_restart *gpio_restart = platform_get_drvdata(pdev); struct gpio_restart *gpio_restart = platform_get_drvdata(pdev);
int ret; int ret;
...@@ -115,10 +115,7 @@ static int gpio_restart_remove(struct platform_device *pdev) ...@@ -115,10 +115,7 @@ static int gpio_restart_remove(struct platform_device *pdev)
dev_err(&pdev->dev, dev_err(&pdev->dev,
"%s: cannot unregister restart handler, %d\n", "%s: cannot unregister restart handler, %d\n",
__func__, ret); __func__, ret);
return -ENODEV;
} }
return 0;
} }
static const struct of_device_id of_gpio_restart_match[] = { static const struct of_device_id of_gpio_restart_match[] = {
...@@ -128,7 +125,7 @@ static const struct of_device_id of_gpio_restart_match[] = { ...@@ -128,7 +125,7 @@ static const struct of_device_id of_gpio_restart_match[] = {
static struct platform_driver gpio_restart_driver = { static struct platform_driver gpio_restart_driver = {
.probe = gpio_restart_probe, .probe = gpio_restart_probe,
.remove = gpio_restart_remove, .remove_new = gpio_restart_remove,
.driver = { .driver = {
.name = "restart-gpio", .name = "restart-gpio",
.of_match_table = of_gpio_restart_match, .of_match_table = of_gpio_restart_match,
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#define GEN1_REASON_SHIFT 2 #define GEN1_REASON_SHIFT 2
#define GEN2_REASON_SHIFT 1 #define GEN2_REASON_SHIFT 1
#define NO_REASON_SHIFT 0
struct pm8916_pon { struct pm8916_pon {
struct device *dev; struct device *dev;
struct regmap *regmap; struct regmap *regmap;
...@@ -45,6 +47,7 @@ static int pm8916_reboot_mode_write(struct reboot_mode_driver *reboot, ...@@ -45,6 +47,7 @@ static int pm8916_reboot_mode_write(struct reboot_mode_driver *reboot,
static int pm8916_pon_probe(struct platform_device *pdev) static int pm8916_pon_probe(struct platform_device *pdev)
{ {
struct pm8916_pon *pon; struct pm8916_pon *pon;
long reason_shift;
int error; int error;
pon = devm_kzalloc(&pdev->dev, sizeof(*pon), GFP_KERNEL); pon = devm_kzalloc(&pdev->dev, sizeof(*pon), GFP_KERNEL);
...@@ -64,14 +67,18 @@ static int pm8916_pon_probe(struct platform_device *pdev) ...@@ -64,14 +67,18 @@ static int pm8916_pon_probe(struct platform_device *pdev)
if (error) if (error)
return error; return error;
reason_shift = (long)of_device_get_match_data(&pdev->dev);
if (reason_shift != NO_REASON_SHIFT) {
pon->reboot_mode.dev = &pdev->dev; pon->reboot_mode.dev = &pdev->dev;
pon->reason_shift = (long)of_device_get_match_data(&pdev->dev); pon->reason_shift = reason_shift;
pon->reboot_mode.write = pm8916_reboot_mode_write; pon->reboot_mode.write = pm8916_reboot_mode_write;
error = devm_reboot_mode_register(&pdev->dev, &pon->reboot_mode); error = devm_reboot_mode_register(&pdev->dev, &pon->reboot_mode);
if (error) { if (error) {
dev_err(&pdev->dev, "can't register reboot mode\n"); dev_err(&pdev->dev, "can't register reboot mode\n");
return error; return error;
} }
}
platform_set_drvdata(pdev, pon); platform_set_drvdata(pdev, pon);
...@@ -80,6 +87,7 @@ static int pm8916_pon_probe(struct platform_device *pdev) ...@@ -80,6 +87,7 @@ static int pm8916_pon_probe(struct platform_device *pdev)
static const struct of_device_id pm8916_pon_id_table[] = { static const struct of_device_id pm8916_pon_id_table[] = {
{ .compatible = "qcom,pm8916-pon", .data = (void *)GEN1_REASON_SHIFT }, { .compatible = "qcom,pm8916-pon", .data = (void *)GEN1_REASON_SHIFT },
{ .compatible = "qcom,pm8941-pon", .data = (void *)NO_REASON_SHIFT },
{ .compatible = "qcom,pms405-pon", .data = (void *)GEN1_REASON_SHIFT }, { .compatible = "qcom,pms405-pon", .data = (void *)GEN1_REASON_SHIFT },
{ .compatible = "qcom,pm8998-pon", .data = (void *)GEN2_REASON_SHIFT }, { .compatible = "qcom,pm8998-pon", .data = (void *)GEN2_REASON_SHIFT },
{ .compatible = "qcom,pmk8350-pon", .data = (void *)GEN2_REASON_SHIFT }, { .compatible = "qcom,pmk8350-pon", .data = (void *)GEN2_REASON_SHIFT },
......
...@@ -942,4 +942,13 @@ config BATTERY_UG3105 ...@@ -942,4 +942,13 @@ config BATTERY_UG3105
device is off or suspended, the functionality of this driver is device is off or suspended, the functionality of this driver is
limited to reporting capacity only. limited to reporting capacity only.
config CHARGER_QCOM_SMB2
tristate "Qualcomm PMI8998 PMIC charger driver"
depends on MFD_SPMI_PMIC
depends on IIO
help
Say Y here to enable the Qualcomm PMIC Charger driver. This
adds support for the SMB2 switch mode battery charger found
in PMI8998 and related PMICs.
endif # POWER_SUPPLY endif # POWER_SUPPLY
...@@ -110,3 +110,4 @@ obj-$(CONFIG_BATTERY_ACER_A500) += acer_a500_battery.o ...@@ -110,3 +110,4 @@ obj-$(CONFIG_BATTERY_ACER_A500) += acer_a500_battery.o
obj-$(CONFIG_BATTERY_SURFACE) += surface_battery.o obj-$(CONFIG_BATTERY_SURFACE) += surface_battery.o
obj-$(CONFIG_CHARGER_SURFACE) += surface_charger.o obj-$(CONFIG_CHARGER_SURFACE) += surface_charger.o
obj-$(CONFIG_BATTERY_UG3105) += ug3105_battery.o obj-$(CONFIG_BATTERY_UG3105) += ug3105_battery.o
obj-$(CONFIG_CHARGER_QCOM_SMB2) += qcom_pmi8998_charger.o
...@@ -736,7 +736,7 @@ static struct i2c_driver adp5061_driver = { ...@@ -736,7 +736,7 @@ static struct i2c_driver adp5061_driver = {
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
}, },
.probe_new = adp5061_probe, .probe = adp5061_probe,
.id_table = adp5061_id, .id_table = adp5061_id,
}; };
module_i2c_driver(adp5061_driver); module_i2c_driver(adp5061_driver);
......
...@@ -26,45 +26,48 @@ ...@@ -26,45 +26,48 @@
#define DRVNAME "axp20x-usb-power-supply" #define DRVNAME "axp20x-usb-power-supply"
#define AXP192_USB_OTG_STATUS 0x04
#define AXP20X_PWR_STATUS_VBUS_PRESENT BIT(5) #define AXP20X_PWR_STATUS_VBUS_PRESENT BIT(5)
#define AXP20X_PWR_STATUS_VBUS_USED BIT(4) #define AXP20X_PWR_STATUS_VBUS_USED BIT(4)
#define AXP20X_USB_STATUS_VBUS_VALID BIT(2) #define AXP20X_USB_STATUS_VBUS_VALID BIT(2)
#define AXP20X_VBUS_PATH_SEL BIT(7)
#define AXP20X_VBUS_PATH_SEL_OFFSET 7
#define AXP20X_VBUS_VHOLD_uV(b) (4000000 + (((b) >> 3) & 7) * 100000) #define AXP20X_VBUS_VHOLD_uV(b) (4000000 + (((b) >> 3) & 7) * 100000)
#define AXP20X_VBUS_VHOLD_MASK GENMASK(5, 3) #define AXP20X_VBUS_VHOLD_MASK GENMASK(5, 3)
#define AXP20X_VBUS_VHOLD_OFFSET 3 #define AXP20X_VBUS_VHOLD_OFFSET 3
#define AXP20X_VBUS_CLIMIT_MASK 3
#define AXP20X_VBUS_CLIMIT_900mA 0
#define AXP20X_VBUS_CLIMIT_500mA 1
#define AXP20X_VBUS_CLIMIT_100mA 2
#define AXP20X_VBUS_CLIMIT_NONE 3
#define AXP813_VBUS_CLIMIT_900mA 0
#define AXP813_VBUS_CLIMIT_1500mA 1
#define AXP813_VBUS_CLIMIT_2000mA 2
#define AXP813_VBUS_CLIMIT_2500mA 3
#define AXP20X_ADC_EN1_VBUS_CURR BIT(2) #define AXP20X_ADC_EN1_VBUS_CURR BIT(2)
#define AXP20X_ADC_EN1_VBUS_VOLT BIT(3) #define AXP20X_ADC_EN1_VBUS_VOLT BIT(3)
#define AXP20X_VBUS_MON_VBUS_VALID BIT(3)
#define AXP813_BC_EN BIT(0)
/* /*
* Note do not raise the debounce time, we must report Vusb high within * Note do not raise the debounce time, we must report Vusb high within
* 100ms otherwise we get Vbus errors in musb. * 100ms otherwise we get Vbus errors in musb.
*/ */
#define DEBOUNCE_TIME msecs_to_jiffies(50) #define DEBOUNCE_TIME msecs_to_jiffies(50)
struct axp_data {
const struct power_supply_desc *power_desc;
const char * const *irq_names;
unsigned int num_irq_names;
const int *curr_lim_table;
struct reg_field curr_lim_fld;
struct reg_field vbus_valid_bit;
struct reg_field vbus_mon_bit;
struct reg_field usb_bc_en_bit;
struct reg_field vbus_disable_bit;
bool vbus_needs_polling: 1;
};
struct axp20x_usb_power { struct axp20x_usb_power {
struct regmap *regmap; struct regmap *regmap;
struct regmap_field *curr_lim_fld;
struct regmap_field *vbus_valid_bit;
struct regmap_field *vbus_mon_bit;
struct regmap_field *usb_bc_en_bit;
struct regmap_field *vbus_disable_bit;
struct power_supply *supply; struct power_supply *supply;
enum axp20x_variants axp20x_id; const struct axp_data *axp_data;
struct iio_channel *vbus_v; struct iio_channel *vbus_v;
struct iio_channel *vbus_i; struct iio_channel *vbus_i;
struct delayed_work vbus_detect; struct delayed_work vbus_detect;
...@@ -81,7 +84,7 @@ static bool axp20x_usb_vbus_needs_polling(struct axp20x_usb_power *power) ...@@ -81,7 +84,7 @@ static bool axp20x_usb_vbus_needs_polling(struct axp20x_usb_power *power)
* present->absent transition implies an online->offline transition * present->absent transition implies an online->offline transition
* and will trigger the VBUS_REMOVAL IRQ. * and will trigger the VBUS_REMOVAL IRQ.
*/ */
if (power->axp20x_id >= AXP221_ID && !power->online) if (power->axp_data->vbus_needs_polling && !power->online)
return true; return true;
return false; return false;
...@@ -121,60 +124,6 @@ static void axp20x_usb_power_poll_vbus(struct work_struct *work) ...@@ -121,60 +124,6 @@ static void axp20x_usb_power_poll_vbus(struct work_struct *work)
mod_delayed_work(system_power_efficient_wq, &power->vbus_detect, DEBOUNCE_TIME); mod_delayed_work(system_power_efficient_wq, &power->vbus_detect, DEBOUNCE_TIME);
} }
static int axp20x_get_current_max(struct axp20x_usb_power *power, int *val)
{
unsigned int v;
int ret = regmap_read(power->regmap, AXP20X_VBUS_IPSOUT_MGMT, &v);
if (ret)
return ret;
switch (v & AXP20X_VBUS_CLIMIT_MASK) {
case AXP20X_VBUS_CLIMIT_100mA:
if (power->axp20x_id == AXP221_ID)
*val = -1; /* No 100mA limit */
else
*val = 100000;
break;
case AXP20X_VBUS_CLIMIT_500mA:
*val = 500000;
break;
case AXP20X_VBUS_CLIMIT_900mA:
*val = 900000;
break;
case AXP20X_VBUS_CLIMIT_NONE:
*val = -1;
break;
}
return 0;
}
static int axp813_get_current_max(struct axp20x_usb_power *power, int *val)
{
unsigned int v;
int ret = regmap_read(power->regmap, AXP20X_VBUS_IPSOUT_MGMT, &v);
if (ret)
return ret;
switch (v & AXP20X_VBUS_CLIMIT_MASK) {
case AXP813_VBUS_CLIMIT_900mA:
*val = 900000;
break;
case AXP813_VBUS_CLIMIT_1500mA:
*val = 1500000;
break;
case AXP813_VBUS_CLIMIT_2000mA:
*val = 2000000;
break;
case AXP813_VBUS_CLIMIT_2500mA:
*val = 2500000;
break;
}
return 0;
}
static int axp20x_usb_power_get_property(struct power_supply *psy, static int axp20x_usb_power_get_property(struct power_supply *psy,
enum power_supply_property psp, union power_supply_propval *val) enum power_supply_property psp, union power_supply_propval *val)
{ {
...@@ -213,9 +162,12 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, ...@@ -213,9 +162,12 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
val->intval = ret * 1700; /* 1 step = 1.7 mV */ val->intval = ret * 1700; /* 1 step = 1.7 mV */
return 0; return 0;
case POWER_SUPPLY_PROP_CURRENT_MAX: case POWER_SUPPLY_PROP_CURRENT_MAX:
if (power->axp20x_id == AXP813_ID) ret = regmap_field_read(power->curr_lim_fld, &v);
return axp813_get_current_max(power, &val->intval); if (ret)
return axp20x_get_current_max(power, &val->intval); return ret;
val->intval = power->axp_data->curr_lim_table[v];
return 0;
case POWER_SUPPLY_PROP_CURRENT_NOW: case POWER_SUPPLY_PROP_CURRENT_NOW:
if (IS_ENABLED(CONFIG_AXP20X_ADC)) { if (IS_ENABLED(CONFIG_AXP20X_ADC)) {
ret = iio_read_channel_processed(power->vbus_i, ret = iio_read_channel_processed(power->vbus_i,
...@@ -256,16 +208,15 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, ...@@ -256,16 +208,15 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
val->intval = POWER_SUPPLY_HEALTH_GOOD; val->intval = POWER_SUPPLY_HEALTH_GOOD;
if (power->axp20x_id == AXP202_ID) { if (power->vbus_valid_bit) {
ret = regmap_read(power->regmap, ret = regmap_field_read(power->vbus_valid_bit, &v);
AXP20X_USB_OTG_STATUS, &v);
if (ret) if (ret)
return ret; return ret;
if (!(v & AXP20X_USB_STATUS_VBUS_VALID)) if (v == 0)
val->intval = val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
} }
break; break;
case POWER_SUPPLY_PROP_PRESENT: case POWER_SUPPLY_PROP_PRESENT:
val->intval = !!(input & AXP20X_PWR_STATUS_VBUS_PRESENT); val->intval = !!(input & AXP20X_PWR_STATUS_VBUS_PRESENT);
...@@ -280,16 +231,6 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, ...@@ -280,16 +231,6 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
return 0; return 0;
} }
static int axp813_usb_power_set_online(struct axp20x_usb_power *power,
int intval)
{
int val = !intval << AXP20X_VBUS_PATH_SEL_OFFSET;
return regmap_update_bits(power->regmap,
AXP20X_VBUS_IPSOUT_MGMT,
AXP20X_VBUS_PATH_SEL, val);
}
static int axp20x_usb_power_set_voltage_min(struct axp20x_usb_power *power, static int axp20x_usb_power_set_voltage_min(struct axp20x_usb_power *power,
int intval) int intval)
{ {
...@@ -316,50 +257,17 @@ static int axp20x_usb_power_set_voltage_min(struct axp20x_usb_power *power, ...@@ -316,50 +257,17 @@ static int axp20x_usb_power_set_voltage_min(struct axp20x_usb_power *power,
return -EINVAL; return -EINVAL;
} }
static int axp813_usb_power_set_current_max(struct axp20x_usb_power *power, static int axp20x_usb_power_set_current_max(struct axp20x_usb_power *power, int intval)
int intval)
{ {
int val; const unsigned int max = GENMASK(power->axp_data->curr_lim_fld.msb,
power->axp_data->curr_lim_fld.lsb);
switch (intval) {
case 900000:
return regmap_update_bits(power->regmap,
AXP20X_VBUS_IPSOUT_MGMT,
AXP20X_VBUS_CLIMIT_MASK,
AXP813_VBUS_CLIMIT_900mA);
case 1500000:
case 2000000:
case 2500000:
val = (intval - 1000000) / 500000;
return regmap_update_bits(power->regmap,
AXP20X_VBUS_IPSOUT_MGMT,
AXP20X_VBUS_CLIMIT_MASK, val);
default:
return -EINVAL;
}
if (intval == -1)
return -EINVAL; return -EINVAL;
}
static int axp20x_usb_power_set_current_max(struct axp20x_usb_power *power, for (unsigned int i = 0; i <= max; ++i)
int intval) if (power->axp_data->curr_lim_table[i] == intval)
{ return regmap_field_write(power->curr_lim_fld, i);
int val;
switch (intval) {
case 100000:
if (power->axp20x_id == AXP221_ID)
return -EINVAL;
fallthrough;
case 500000:
case 900000:
val = (900000 - intval) / 400000;
return regmap_update_bits(power->regmap,
AXP20X_VBUS_IPSOUT_MGMT,
AXP20X_VBUS_CLIMIT_MASK, val);
default:
return -EINVAL;
}
return -EINVAL; return -EINVAL;
} }
...@@ -372,17 +280,15 @@ static int axp20x_usb_power_set_property(struct power_supply *psy, ...@@ -372,17 +280,15 @@ static int axp20x_usb_power_set_property(struct power_supply *psy,
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_ONLINE: case POWER_SUPPLY_PROP_ONLINE:
if (power->axp20x_id != AXP813_ID) if (!power->vbus_disable_bit)
return -EINVAL; return -EINVAL;
return axp813_usb_power_set_online(power, val->intval);
return regmap_field_write(power->vbus_disable_bit, !val->intval);
case POWER_SUPPLY_PROP_VOLTAGE_MIN: case POWER_SUPPLY_PROP_VOLTAGE_MIN:
return axp20x_usb_power_set_voltage_min(power, val->intval); return axp20x_usb_power_set_voltage_min(power, val->intval);
case POWER_SUPPLY_PROP_CURRENT_MAX: case POWER_SUPPLY_PROP_CURRENT_MAX:
if (power->axp20x_id == AXP813_ID)
return axp813_usb_power_set_current_max(power,
val->intval);
return axp20x_usb_power_set_current_max(power, val->intval); return axp20x_usb_power_set_current_max(power, val->intval);
default: default:
...@@ -405,7 +311,7 @@ static int axp20x_usb_power_prop_writeable(struct power_supply *psy, ...@@ -405,7 +311,7 @@ static int axp20x_usb_power_prop_writeable(struct power_supply *psy,
* the VBUS input offline. * the VBUS input offline.
*/ */
if (psp == POWER_SUPPLY_PROP_ONLINE) if (psp == POWER_SUPPLY_PROP_ONLINE)
return power->axp20x_id == AXP813_ID; return power->vbus_disable_bit != NULL;
return psp == POWER_SUPPLY_PROP_VOLTAGE_MIN || return psp == POWER_SUPPLY_PROP_VOLTAGE_MIN ||
psp == POWER_SUPPLY_PROP_CURRENT_MAX; psp == POWER_SUPPLY_PROP_CURRENT_MAX;
...@@ -461,39 +367,81 @@ static const char * const axp22x_irq_names[] = { ...@@ -461,39 +367,81 @@ static const char * const axp22x_irq_names[] = {
"VBUS_REMOVAL", "VBUS_REMOVAL",
}; };
struct axp_data { static int axp192_usb_curr_lim_table[] = {
const struct power_supply_desc *power_desc; -1,
const char * const *irq_names; -1,
unsigned int num_irq_names; 500000,
enum axp20x_variants axp20x_id; 100000,
};
static int axp20x_usb_curr_lim_table[] = {
900000,
500000,
100000,
-1,
};
static int axp221_usb_curr_lim_table[] = {
900000,
500000,
-1,
-1,
};
static int axp813_usb_curr_lim_table[] = {
900000,
1500000,
2000000,
2500000,
};
static const struct axp_data axp192_data = {
.power_desc = &axp20x_usb_power_desc,
.irq_names = axp20x_irq_names,
.num_irq_names = ARRAY_SIZE(axp20x_irq_names),
.curr_lim_table = axp192_usb_curr_lim_table,
.curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1),
.vbus_valid_bit = REG_FIELD(AXP192_USB_OTG_STATUS, 2, 2),
.vbus_mon_bit = REG_FIELD(AXP20X_VBUS_MON, 3, 3),
}; };
static const struct axp_data axp202_data = { static const struct axp_data axp202_data = {
.power_desc = &axp20x_usb_power_desc, .power_desc = &axp20x_usb_power_desc,
.irq_names = axp20x_irq_names, .irq_names = axp20x_irq_names,
.num_irq_names = ARRAY_SIZE(axp20x_irq_names), .num_irq_names = ARRAY_SIZE(axp20x_irq_names),
.axp20x_id = AXP202_ID, .curr_lim_table = axp20x_usb_curr_lim_table,
.curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1),
.vbus_valid_bit = REG_FIELD(AXP20X_USB_OTG_STATUS, 2, 2),
.vbus_mon_bit = REG_FIELD(AXP20X_VBUS_MON, 3, 3),
}; };
static const struct axp_data axp221_data = { static const struct axp_data axp221_data = {
.power_desc = &axp22x_usb_power_desc, .power_desc = &axp22x_usb_power_desc,
.irq_names = axp22x_irq_names, .irq_names = axp22x_irq_names,
.num_irq_names = ARRAY_SIZE(axp22x_irq_names), .num_irq_names = ARRAY_SIZE(axp22x_irq_names),
.axp20x_id = AXP221_ID, .curr_lim_table = axp221_usb_curr_lim_table,
.curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1),
.vbus_needs_polling = true,
}; };
static const struct axp_data axp223_data = { static const struct axp_data axp223_data = {
.power_desc = &axp22x_usb_power_desc, .power_desc = &axp22x_usb_power_desc,
.irq_names = axp22x_irq_names, .irq_names = axp22x_irq_names,
.num_irq_names = ARRAY_SIZE(axp22x_irq_names), .num_irq_names = ARRAY_SIZE(axp22x_irq_names),
.axp20x_id = AXP223_ID, .curr_lim_table = axp20x_usb_curr_lim_table,
.curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1),
.vbus_needs_polling = true,
}; };
static const struct axp_data axp813_data = { static const struct axp_data axp813_data = {
.power_desc = &axp22x_usb_power_desc, .power_desc = &axp22x_usb_power_desc,
.irq_names = axp22x_irq_names, .irq_names = axp22x_irq_names,
.num_irq_names = ARRAY_SIZE(axp22x_irq_names), .num_irq_names = ARRAY_SIZE(axp22x_irq_names),
.axp20x_id = AXP813_ID, .curr_lim_table = axp813_usb_curr_lim_table,
.curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1),
.usb_bc_en_bit = REG_FIELD(AXP288_BC_GLOBAL, 0, 0),
.vbus_disable_bit = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 7, 7),
.vbus_needs_polling = true,
}; };
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
...@@ -565,6 +513,26 @@ static int configure_adc_registers(struct axp20x_usb_power *power) ...@@ -565,6 +513,26 @@ static int configure_adc_registers(struct axp20x_usb_power *power)
AXP20X_ADC_EN1_VBUS_VOLT); AXP20X_ADC_EN1_VBUS_VOLT);
} }
static int axp20x_regmap_field_alloc_optional(struct device *dev,
struct regmap *regmap,
struct reg_field fdesc,
struct regmap_field **fieldp)
{
struct regmap_field *field;
if (fdesc.reg == 0) {
*fieldp = NULL;
return 0;
}
field = devm_regmap_field_alloc(dev, regmap, fdesc);
if (IS_ERR(field))
return PTR_ERR(field);
*fieldp = field;
return 0;
}
static int axp20x_usb_power_probe(struct platform_device *pdev) static int axp20x_usb_power_probe(struct platform_device *pdev)
{ {
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
...@@ -591,20 +559,47 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) ...@@ -591,20 +559,47 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, power); platform_set_drvdata(pdev, power);
power->axp20x_id = axp_data->axp20x_id; power->axp_data = axp_data;
power->regmap = axp20x->regmap; power->regmap = axp20x->regmap;
power->num_irqs = axp_data->num_irq_names; power->num_irqs = axp_data->num_irq_names;
power->curr_lim_fld = devm_regmap_field_alloc(&pdev->dev, power->regmap,
axp_data->curr_lim_fld);
if (IS_ERR(power->curr_lim_fld))
return PTR_ERR(power->curr_lim_fld);
ret = axp20x_regmap_field_alloc_optional(&pdev->dev, power->regmap,
axp_data->vbus_valid_bit,
&power->vbus_valid_bit);
if (ret)
return ret;
ret = axp20x_regmap_field_alloc_optional(&pdev->dev, power->regmap,
axp_data->vbus_mon_bit,
&power->vbus_mon_bit);
if (ret)
return ret;
ret = axp20x_regmap_field_alloc_optional(&pdev->dev, power->regmap,
axp_data->usb_bc_en_bit,
&power->usb_bc_en_bit);
if (ret)
return ret;
ret = axp20x_regmap_field_alloc_optional(&pdev->dev, power->regmap,
axp_data->vbus_disable_bit,
&power->vbus_disable_bit);
if (ret)
return ret;
ret = devm_delayed_work_autocancel(&pdev->dev, &power->vbus_detect, ret = devm_delayed_work_autocancel(&pdev->dev, &power->vbus_detect,
axp20x_usb_power_poll_vbus); axp20x_usb_power_poll_vbus);
if (ret) if (ret)
return ret; return ret;
if (power->axp20x_id == AXP202_ID) { if (power->vbus_mon_bit) {
/* Enable vbus valid checking */ /* Enable vbus valid checking */
ret = regmap_update_bits(power->regmap, AXP20X_VBUS_MON, ret = regmap_field_write(power->vbus_mon_bit, 1);
AXP20X_VBUS_MON_VBUS_VALID,
AXP20X_VBUS_MON_VBUS_VALID);
if (ret) if (ret)
return ret; return ret;
...@@ -617,10 +612,9 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) ...@@ -617,10 +612,9 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
return ret; return ret;
} }
if (power->axp20x_id == AXP813_ID) { if (power->usb_bc_en_bit) {
/* Enable USB Battery Charging specification detection */ /* Enable USB Battery Charging specification detection */
ret = regmap_update_bits(axp20x->regmap, AXP288_BC_GLOBAL, ret = regmap_field_write(power->usb_bc_en_bit, 1);
AXP813_BC_EN, AXP813_BC_EN);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -659,6 +653,9 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) ...@@ -659,6 +653,9 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
static const struct of_device_id axp20x_usb_power_match[] = { static const struct of_device_id axp20x_usb_power_match[] = {
{ {
.compatible = "x-powers,axp192-usb-power-supply",
.data = &axp192_data,
}, {
.compatible = "x-powers,axp202-usb-power-supply", .compatible = "x-powers,axp202-usb-power-supply",
.data = &axp202_data, .data = &axp202_data,
}, { }, {
......
...@@ -1077,7 +1077,7 @@ static struct i2c_driver bd9995x_driver = { ...@@ -1077,7 +1077,7 @@ static struct i2c_driver bd9995x_driver = {
.name = "bd9995x-charger", .name = "bd9995x-charger",
.of_match_table = bd9995x_of_match, .of_match_table = bd9995x_of_match,
}, },
.probe_new = bd9995x_probe, .probe = bd9995x_probe,
}; };
module_i2c_driver(bd9995x_driver); module_i2c_driver(bd9995x_driver);
......
...@@ -1780,7 +1780,7 @@ static struct i2c_driver bq2415x_driver = { ...@@ -1780,7 +1780,7 @@ static struct i2c_driver bq2415x_driver = {
.of_match_table = of_match_ptr(bq2415x_of_match_table), .of_match_table = of_match_ptr(bq2415x_of_match_table),
.acpi_match_table = ACPI_PTR(bq2415x_i2c_acpi_match), .acpi_match_table = ACPI_PTR(bq2415x_i2c_acpi_match),
}, },
.probe_new = bq2415x_probe, .probe = bq2415x_probe,
.remove = bq2415x_remove, .remove = bq2415x_remove,
.id_table = bq2415x_i2c_id_table, .id_table = bq2415x_i2c_id_table,
}; };
......
...@@ -2034,7 +2034,7 @@ static const struct of_device_id bq24190_of_match[] = { ...@@ -2034,7 +2034,7 @@ static const struct of_device_id bq24190_of_match[] = {
MODULE_DEVICE_TABLE(of, bq24190_of_match); MODULE_DEVICE_TABLE(of, bq24190_of_match);
static struct i2c_driver bq24190_driver = { static struct i2c_driver bq24190_driver = {
.probe_new = bq24190_probe, .probe = bq24190_probe,
.remove = bq24190_remove, .remove = bq24190_remove,
.shutdown = bq24190_shutdown, .shutdown = bq24190_shutdown,
.id_table = bq24190_i2c_ids, .id_table = bq24190_i2c_ids,
......
...@@ -1165,7 +1165,7 @@ static struct i2c_driver bq24257_driver = { ...@@ -1165,7 +1165,7 @@ static struct i2c_driver bq24257_driver = {
.acpi_match_table = ACPI_PTR(bq24257_acpi_match), .acpi_match_table = ACPI_PTR(bq24257_acpi_match),
.pm = &bq24257_pm, .pm = &bq24257_pm,
}, },
.probe_new = bq24257_probe, .probe = bq24257_probe,
.remove = bq24257_remove, .remove = bq24257_remove,
.id_table = bq24257_i2c_ids, .id_table = bq24257_i2c_ids,
}; };
......
...@@ -505,7 +505,7 @@ static struct i2c_driver bq24735_charger_driver = { ...@@ -505,7 +505,7 @@ static struct i2c_driver bq24735_charger_driver = {
.name = "bq24735-charger", .name = "bq24735-charger",
.of_match_table = bq24735_match_ids, .of_match_table = bq24735_match_ids,
}, },
.probe_new = bq24735_charger_probe, .probe = bq24735_charger_probe,
.id_table = bq24735_charger_id, .id_table = bq24735_charger_id,
}; };
......
...@@ -1158,7 +1158,7 @@ static struct i2c_driver bq2515x_driver = { ...@@ -1158,7 +1158,7 @@ static struct i2c_driver bq2515x_driver = {
.name = "bq2515x-charger", .name = "bq2515x-charger",
.of_match_table = bq2515x_of_match, .of_match_table = bq2515x_of_match,
}, },
.probe_new = bq2515x_probe, .probe = bq2515x_probe,
.id_table = bq2515x_i2c_ids, .id_table = bq2515x_i2c_ids,
}; };
module_i2c_driver(bq2515x_driver); module_i2c_driver(bq2515x_driver);
......
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
#define BQ256XX_IINDPM_MAX_uA 3200000 #define BQ256XX_IINDPM_MAX_uA 3200000
#define BQ256XX_IINDPM_DEF_uA 2400000 #define BQ256XX_IINDPM_DEF_uA 2400000
#define BQ256XX_TS_IGNORE BIT(6)
#define BQ256XX_TS_IGNORE_SHIFT 6
#define BQ256XX_VINDPM_MASK GENMASK(3, 0) #define BQ256XX_VINDPM_MASK GENMASK(3, 0)
#define BQ256XX_VINDPM_STEP_uV 100000 #define BQ256XX_VINDPM_STEP_uV 100000
#define BQ256XX_VINDPM_OFFSET_uV 3900000 #define BQ256XX_VINDPM_OFFSET_uV 3900000
...@@ -156,6 +159,7 @@ ...@@ -156,6 +159,7 @@
* @vindpm: input voltage limit * @vindpm: input voltage limit
* @ichg_max: maximum fast charge current * @ichg_max: maximum fast charge current
* @vbatreg_max: maximum charge voltage * @vbatreg_max: maximum charge voltage
* @ts_ignore: TS_IGNORE flag
*/ */
struct bq256xx_init_data { struct bq256xx_init_data {
u32 ichg; u32 ichg;
...@@ -166,6 +170,7 @@ struct bq256xx_init_data { ...@@ -166,6 +170,7 @@ struct bq256xx_init_data {
u32 vindpm; u32 vindpm;
u32 ichg_max; u32 ichg_max;
u32 vbatreg_max; u32 vbatreg_max;
bool ts_ignore;
}; };
/** /**
...@@ -263,6 +268,7 @@ struct bq256xx_device { ...@@ -263,6 +268,7 @@ struct bq256xx_device {
* @bq256xx_set_iprechg: pointer to instance specific set_iprechg function * @bq256xx_set_iprechg: pointer to instance specific set_iprechg function
* @bq256xx_set_vindpm: pointer to instance specific set_vindpm function * @bq256xx_set_vindpm: pointer to instance specific set_vindpm function
* @bq256xx_set_charge_type: pointer to instance specific set_charge_type function * @bq256xx_set_charge_type: pointer to instance specific set_charge_type function
* @bq256xx_set_ts_ignore: pointer to instance specific set_ts_ignore function
* *
* @bq256xx_def_ichg: default ichg value in microamps * @bq256xx_def_ichg: default ichg value in microamps
* @bq256xx_def_iindpm: default iindpm value in microamps * @bq256xx_def_iindpm: default iindpm value in microamps
...@@ -295,6 +301,7 @@ struct bq256xx_chip_info { ...@@ -295,6 +301,7 @@ struct bq256xx_chip_info {
int (*bq256xx_set_iprechg)(struct bq256xx_device *bq, int iprechg); int (*bq256xx_set_iprechg)(struct bq256xx_device *bq, int iprechg);
int (*bq256xx_set_vindpm)(struct bq256xx_device *bq, int vindpm); int (*bq256xx_set_vindpm)(struct bq256xx_device *bq, int vindpm);
int (*bq256xx_set_charge_type)(struct bq256xx_device *bq, int type); int (*bq256xx_set_charge_type)(struct bq256xx_device *bq, int type);
int (*bq256xx_set_ts_ignore)(struct bq256xx_device *bq, bool ts_ignore);
int bq256xx_def_ichg; int bq256xx_def_ichg;
int bq256xx_def_iindpm; int bq256xx_def_iindpm;
...@@ -696,6 +703,12 @@ static int bq25601d_set_chrg_volt(struct bq256xx_device *bq, int vbatreg) ...@@ -696,6 +703,12 @@ static int bq25601d_set_chrg_volt(struct bq256xx_device *bq, int vbatreg)
BQ256XX_VBATREG_BIT_SHIFT); BQ256XX_VBATREG_BIT_SHIFT);
} }
static int bq256xx_set_ts_ignore(struct bq256xx_device *bq, bool ts_ignore)
{
return regmap_update_bits(bq->regmap, BQ256XX_INPUT_CURRENT_LIMIT,
BQ256XX_TS_IGNORE, (ts_ignore ? 1 : 0) << BQ256XX_TS_IGNORE_SHIFT);
}
static int bq256xx_get_prechrg_curr(struct bq256xx_device *bq) static int bq256xx_get_prechrg_curr(struct bq256xx_device *bq)
{ {
unsigned int prechg_and_term_curr_lim; unsigned int prechg_and_term_curr_lim;
...@@ -1312,6 +1325,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { ...@@ -1312,6 +1325,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_get_iterm = bq256xx_get_term_curr, .bq256xx_get_iterm = bq256xx_get_term_curr,
.bq256xx_get_iprechg = bq256xx_get_prechrg_curr, .bq256xx_get_iprechg = bq256xx_get_prechrg_curr,
.bq256xx_get_vindpm = bq256xx_get_input_volt_lim, .bq256xx_get_vindpm = bq256xx_get_input_volt_lim,
.bq256xx_set_ts_ignore = NULL,
.bq256xx_set_ichg = bq256xx_set_ichg_curr, .bq256xx_set_ichg = bq256xx_set_ichg_curr,
.bq256xx_set_iindpm = bq256xx_set_input_curr_lim, .bq256xx_set_iindpm = bq256xx_set_input_curr_lim,
...@@ -1351,6 +1365,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { ...@@ -1351,6 +1365,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type, .bq256xx_set_charge_type = bq256xx_set_charge_type,
.bq256xx_set_ts_ignore = NULL,
.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
...@@ -1382,6 +1397,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { ...@@ -1382,6 +1397,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type, .bq256xx_set_charge_type = bq256xx_set_charge_type,
.bq256xx_set_ts_ignore = NULL,
.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
...@@ -1413,6 +1429,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { ...@@ -1413,6 +1429,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type, .bq256xx_set_charge_type = bq256xx_set_charge_type,
.bq256xx_set_ts_ignore = NULL,
.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
...@@ -1444,6 +1461,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { ...@@ -1444,6 +1461,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type, .bq256xx_set_charge_type = bq256xx_set_charge_type,
.bq256xx_set_ts_ignore = bq256xx_set_ts_ignore,
.bq256xx_def_ichg = BQ25611D_ICHG_DEF_uA, .bq256xx_def_ichg = BQ25611D_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
...@@ -1475,6 +1493,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { ...@@ -1475,6 +1493,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq25618_619_set_prechrg_curr, .bq256xx_set_iprechg = bq25618_619_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type, .bq256xx_set_charge_type = bq256xx_set_charge_type,
.bq256xx_set_ts_ignore = bq256xx_set_ts_ignore,
.bq256xx_def_ichg = BQ25618_ICHG_DEF_uA, .bq256xx_def_ichg = BQ25618_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
...@@ -1506,6 +1525,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { ...@@ -1506,6 +1525,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iprechg = bq25618_619_set_prechrg_curr, .bq256xx_set_iprechg = bq25618_619_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type, .bq256xx_set_charge_type = bq256xx_set_charge_type,
.bq256xx_set_ts_ignore = bq256xx_set_ts_ignore,
.bq256xx_def_ichg = BQ25618_ICHG_DEF_uA, .bq256xx_def_ichg = BQ25618_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
...@@ -1622,6 +1642,12 @@ static int bq256xx_hw_init(struct bq256xx_device *bq) ...@@ -1622,6 +1642,12 @@ static int bq256xx_hw_init(struct bq256xx_device *bq)
if (ret) if (ret)
return ret; return ret;
if (bq->chip_info->bq256xx_set_ts_ignore) {
ret = bq->chip_info->bq256xx_set_ts_ignore(bq, bq->init_data.ts_ignore);
if (ret)
return ret;
}
power_supply_put_battery_info(bq->charger, bat_info); power_supply_put_battery_info(bq->charger, bat_info);
return 0; return 0;
...@@ -1656,6 +1682,8 @@ static int bq256xx_parse_dt(struct bq256xx_device *bq, ...@@ -1656,6 +1682,8 @@ static int bq256xx_parse_dt(struct bq256xx_device *bq,
if (ret) if (ret)
bq->init_data.iindpm = bq->chip_info->bq256xx_def_iindpm; bq->init_data.iindpm = bq->chip_info->bq256xx_def_iindpm;
bq->init_data.ts_ignore = device_property_read_bool(bq->dev, "ti,no-thermistor");
return 0; return 0;
} }
...@@ -1784,7 +1812,7 @@ static struct i2c_driver bq256xx_driver = { ...@@ -1784,7 +1812,7 @@ static struct i2c_driver bq256xx_driver = {
.of_match_table = bq256xx_of_match, .of_match_table = bq256xx_of_match,
.acpi_match_table = bq256xx_acpi_match, .acpi_match_table = bq256xx_acpi_match,
}, },
.probe_new = bq256xx_probe, .probe = bq256xx_probe,
.id_table = bq256xx_i2c_ids, .id_table = bq256xx_i2c_ids,
}; };
module_i2c_driver(bq256xx_driver); module_i2c_driver(bq256xx_driver);
......
...@@ -1649,7 +1649,7 @@ static struct i2c_driver bq25890_driver = { ...@@ -1649,7 +1649,7 @@ static struct i2c_driver bq25890_driver = {
.acpi_match_table = ACPI_PTR(bq25890_acpi_match), .acpi_match_table = ACPI_PTR(bq25890_acpi_match),
.pm = &bq25890_pm, .pm = &bq25890_pm,
}, },
.probe_new = bq25890_probe, .probe = bq25890_probe,
.remove = bq25890_remove, .remove = bq25890_remove,
.shutdown = bq25890_shutdown, .shutdown = bq25890_shutdown,
.id_table = bq25890_i2c_ids, .id_table = bq25890_i2c_ids,
......
...@@ -1287,7 +1287,7 @@ static struct i2c_driver bq25980_driver = { ...@@ -1287,7 +1287,7 @@ static struct i2c_driver bq25980_driver = {
.name = "bq25980-charger", .name = "bq25980-charger",
.of_match_table = bq25980_of_match, .of_match_table = bq25980_of_match,
}, },
.probe_new = bq25980_probe, .probe = bq25980_probe,
.id_table = bq25980_i2c_ids, .id_table = bq25980_i2c_ids,
}; };
module_i2c_driver(bq25980_driver); module_i2c_driver(bq25980_driver);
......
...@@ -296,7 +296,7 @@ static struct i2c_driver bq27xxx_battery_i2c_driver = { ...@@ -296,7 +296,7 @@ static struct i2c_driver bq27xxx_battery_i2c_driver = {
.name = "bq27xxx-battery", .name = "bq27xxx-battery",
.of_match_table = of_match_ptr(bq27xxx_battery_i2c_of_match_table), .of_match_table = of_match_ptr(bq27xxx_battery_i2c_of_match_table),
}, },
.probe_new = bq27xxx_battery_i2c_probe, .probe = bq27xxx_battery_i2c_probe,
.remove = bq27xxx_battery_i2c_remove, .remove = bq27xxx_battery_i2c_remove,
.id_table = bq27xxx_i2c_id_table, .id_table = bq27xxx_i2c_id_table,
}; };
......
...@@ -227,8 +227,7 @@ static int cros_pchg_get_prop(struct power_supply *psy, ...@@ -227,8 +227,7 @@ static int cros_pchg_get_prop(struct power_supply *psy,
return 0; return 0;
} }
static int cros_pchg_event(const struct charger_data *charger, static int cros_pchg_event(const struct charger_data *charger)
unsigned long host_event)
{ {
int i; int i;
...@@ -256,7 +255,7 @@ static int cros_ec_notify(struct notifier_block *nb, ...@@ -256,7 +255,7 @@ static int cros_ec_notify(struct notifier_block *nb,
if (!(host_event & EC_MKBP_PCHG_DEVICE_EVENT)) if (!(host_event & EC_MKBP_PCHG_DEVICE_EVENT))
return NOTIFY_DONE; return NOTIFY_DONE;
return cros_pchg_event(charger, host_event); return cros_pchg_event(charger);
} }
static int cros_pchg_probe(struct platform_device *pdev) static int cros_pchg_probe(struct platform_device *pdev)
...@@ -281,6 +280,8 @@ static int cros_pchg_probe(struct platform_device *pdev) ...@@ -281,6 +280,8 @@ static int cros_pchg_probe(struct platform_device *pdev)
charger->ec_dev = ec_dev; charger->ec_dev = ec_dev;
charger->ec_device = ec_device; charger->ec_device = ec_device;
platform_set_drvdata(pdev, charger);
ret = cros_pchg_port_count(charger); ret = cros_pchg_port_count(charger);
if (ret <= 0) { if (ret <= 0) {
/* /*
...@@ -349,9 +350,27 @@ static int cros_pchg_probe(struct platform_device *pdev) ...@@ -349,9 +350,27 @@ static int cros_pchg_probe(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_PM_SLEEP
static int __maybe_unused cros_pchg_resume(struct device *dev)
{
struct charger_data *charger = dev_get_drvdata(dev);
/*
* Sync all ports on resume in case reports from EC are lost during
* the last suspend.
*/
cros_pchg_event(charger);
return 0;
}
#endif
static SIMPLE_DEV_PM_OPS(cros_pchg_pm_ops, NULL, cros_pchg_resume);
static struct platform_driver cros_pchg_driver = { static struct platform_driver cros_pchg_driver = {
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.pm = &cros_pchg_pm_ops,
}, },
.probe = cros_pchg_probe .probe = cros_pchg_probe
}; };
......
...@@ -747,7 +747,7 @@ static struct i2c_driver cw_bat_driver = { ...@@ -747,7 +747,7 @@ static struct i2c_driver cw_bat_driver = {
.of_match_table = cw2015_of_match, .of_match_table = cw2015_of_match,
.pm = &cw_bat_pm_ops, .pm = &cw_bat_pm_ops,
}, },
.probe_new = cw_bat_probe, .probe = cw_bat_probe,
.id_table = cw_bat_id_table, .id_table = cw_bat_id_table,
}; };
......
...@@ -458,7 +458,7 @@ static struct i2c_driver ds278x_battery_driver = { ...@@ -458,7 +458,7 @@ static struct i2c_driver ds278x_battery_driver = {
.name = "ds2782-battery", .name = "ds2782-battery",
.pm = &ds278x_battery_pm_ops, .pm = &ds278x_battery_pm_ops,
}, },
.probe_new = ds278x_battery_probe, .probe = ds278x_battery_probe,
.remove = ds278x_battery_remove, .remove = ds278x_battery_remove,
.id_table = ds278x_id, .id_table = ds278x_id,
}; };
......
...@@ -625,7 +625,7 @@ static const struct of_device_id ip5xxx_power_of_match[] = { ...@@ -625,7 +625,7 @@ static const struct of_device_id ip5xxx_power_of_match[] = {
MODULE_DEVICE_TABLE(of, ip5xxx_power_of_match); MODULE_DEVICE_TABLE(of, ip5xxx_power_of_match);
static struct i2c_driver ip5xxx_power_driver = { static struct i2c_driver ip5xxx_power_driver = {
.probe_new = ip5xxx_power_probe, .probe = ip5xxx_power_probe,
.driver = { .driver = {
.name = "ip5xxx-power", .name = "ip5xxx-power",
.of_match_table = ip5xxx_power_of_match, .of_match_table = ip5xxx_power_of_match,
......
...@@ -615,7 +615,7 @@ static struct i2c_driver lp8727_driver = { ...@@ -615,7 +615,7 @@ static struct i2c_driver lp8727_driver = {
.name = "lp8727", .name = "lp8727",
.of_match_table = of_match_ptr(lp8727_dt_ids), .of_match_table = of_match_ptr(lp8727_dt_ids),
}, },
.probe_new = lp8727_probe, .probe = lp8727_probe,
.remove = lp8727_remove, .remove = lp8727_remove,
.id_table = lp8727_ids, .id_table = lp8727_ids,
}; };
......
...@@ -635,7 +635,7 @@ static struct i2c_driver ltc294x_driver = { ...@@ -635,7 +635,7 @@ static struct i2c_driver ltc294x_driver = {
.of_match_table = ltc294x_i2c_of_match, .of_match_table = ltc294x_i2c_of_match,
.pm = LTC294X_PM_OPS, .pm = LTC294X_PM_OPS,
}, },
.probe_new = ltc294x_i2c_probe, .probe = ltc294x_i2c_probe,
.shutdown = ltc294x_i2c_shutdown, .shutdown = ltc294x_i2c_shutdown,
.id_table = ltc294x_i2c_id, .id_table = ltc294x_i2c_id,
}; };
......
...@@ -915,7 +915,7 @@ static const struct of_device_id ltc4162l_of_match[] __maybe_unused = { ...@@ -915,7 +915,7 @@ static const struct of_device_id ltc4162l_of_match[] __maybe_unused = {
MODULE_DEVICE_TABLE(of, ltc4162l_of_match); MODULE_DEVICE_TABLE(of, ltc4162l_of_match);
static struct i2c_driver ltc4162l_driver = { static struct i2c_driver ltc4162l_driver = {
.probe_new = ltc4162l_probe, .probe = ltc4162l_probe,
.alert = ltc4162l_alert, .alert = ltc4162l_alert,
.id_table = ltc4162l_i2c_id_table, .id_table = ltc4162l_i2c_id_table,
.driver = { .driver = {
......
...@@ -316,7 +316,7 @@ static struct i2c_driver max14656_i2c_driver = { ...@@ -316,7 +316,7 @@ static struct i2c_driver max14656_i2c_driver = {
.name = "max14656", .name = "max14656",
.of_match_table = max14656_match_table, .of_match_table = max14656_match_table,
}, },
.probe_new = max14656_probe, .probe = max14656_probe,
.id_table = max14656_id, .id_table = max14656_id,
}; };
module_i2c_driver(max14656_i2c_driver); module_i2c_driver(max14656_i2c_driver);
......
...@@ -599,7 +599,7 @@ static struct i2c_driver max17040_i2c_driver = { ...@@ -599,7 +599,7 @@ static struct i2c_driver max17040_i2c_driver = {
.of_match_table = max17040_of_match, .of_match_table = max17040_of_match,
.pm = MAX17040_PM_OPS, .pm = MAX17040_PM_OPS,
}, },
.probe_new = max17040_probe, .probe = max17040_probe,
.id_table = max17040_id, .id_table = max17040_id,
}; };
module_i2c_driver(max17040_i2c_driver); module_i2c_driver(max17040_i2c_driver);
......
...@@ -499,11 +499,6 @@ static int max17042_property_is_writeable(struct power_supply *psy, ...@@ -499,11 +499,6 @@ static int max17042_property_is_writeable(struct power_supply *psy,
return ret; return ret;
} }
static void max17042_external_power_changed(struct power_supply *psy)
{
power_supply_changed(psy);
}
static int max17042_write_verify_reg(struct regmap *map, u8 reg, u32 value) static int max17042_write_verify_reg(struct regmap *map, u8 reg, u32 value)
{ {
int retries = 8; int retries = 8;
...@@ -1016,7 +1011,7 @@ static const struct power_supply_desc max17042_psy_desc = { ...@@ -1016,7 +1011,7 @@ static const struct power_supply_desc max17042_psy_desc = {
.get_property = max17042_get_property, .get_property = max17042_get_property,
.set_property = max17042_set_property, .set_property = max17042_set_property,
.property_is_writeable = max17042_property_is_writeable, .property_is_writeable = max17042_property_is_writeable,
.external_power_changed = max17042_external_power_changed, .external_power_changed = power_supply_changed,
.properties = max17042_battery_props, .properties = max17042_battery_props,
.num_properties = ARRAY_SIZE(max17042_battery_props), .num_properties = ARRAY_SIZE(max17042_battery_props),
}; };
...@@ -1220,7 +1215,7 @@ static struct i2c_driver max17042_i2c_driver = { ...@@ -1220,7 +1215,7 @@ static struct i2c_driver max17042_i2c_driver = {
.of_match_table = of_match_ptr(max17042_dt_match), .of_match_table = of_match_ptr(max17042_dt_match),
.pm = &max17042_pm_ops, .pm = &max17042_pm_ops,
}, },
.probe_new = max17042_probe, .probe = max17042_probe,
.id_table = max17042_id, .id_table = max17042_id,
}; };
module_i2c_driver(max17042_i2c_driver); module_i2c_driver(max17042_i2c_driver);
......
...@@ -499,7 +499,7 @@ static struct i2c_driver max77976_driver = { ...@@ -499,7 +499,7 @@ static struct i2c_driver max77976_driver = {
.name = MAX77976_DRIVER_NAME, .name = MAX77976_DRIVER_NAME,
.of_match_table = max77976_of_id, .of_match_table = max77976_of_id,
}, },
.probe_new = max77976_probe, .probe = max77976_probe,
.id_table = max77976_i2c_id, .id_table = max77976_i2c_id,
}; };
module_i2c_driver(max77976_driver); module_i2c_driver(max77976_driver);
......
...@@ -293,7 +293,7 @@ static const struct hwmon_ops power_supply_hwmon_ops = { ...@@ -293,7 +293,7 @@ static const struct hwmon_ops power_supply_hwmon_ops = {
.read_string = power_supply_hwmon_read_string, .read_string = power_supply_hwmon_read_string,
}; };
static const struct hwmon_channel_info *power_supply_hwmon_info[] = { static const struct hwmon_channel_info * const power_supply_hwmon_info[] = {
HWMON_CHANNEL_INFO(temp, HWMON_CHANNEL_INFO(temp,
HWMON_T_LABEL | HWMON_T_LABEL |
HWMON_T_INPUT | HWMON_T_INPUT |
......
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
* Copyright (c) 2023, Linaro Ltd.
* Author: Caleb Connolly <caleb.connolly@linaro.org>
*
* This driver is for the switch-mode battery charger and boost
* hardware found in pmi8998 and related PMICs.
*/
#include <linux/bits.h>
#include <linux/devm-helpers.h>
#include <linux/iio/consumer.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/minmax.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_wakeirq.h>
#include <linux/of.h>
#include <linux/power_supply.h>
#include <linux/regmap.h>
#include <linux/types.h>
#include <linux/workqueue.h>
/* clang-format off */
#define BATTERY_CHARGER_STATUS_1 0x06
#define BVR_INITIAL_RAMP_BIT BIT(7)
#define CC_SOFT_TERMINATE_BIT BIT(6)
#define STEP_CHARGING_STATUS_SHIFT 3
#define STEP_CHARGING_STATUS_MASK GENMASK(5, 3)
#define BATTERY_CHARGER_STATUS_MASK GENMASK(2, 0)
#define BATTERY_CHARGER_STATUS_2 0x07
#define INPUT_CURRENT_LIMITED_BIT BIT(7)
#define CHARGER_ERROR_STATUS_SFT_EXPIRE_BIT BIT(6)
#define CHARGER_ERROR_STATUS_BAT_OV_BIT BIT(5)
#define CHARGER_ERROR_STATUS_BAT_TERM_MISSING_BIT BIT(4)
#define BAT_TEMP_STATUS_MASK GENMASK(3, 0)
#define BAT_TEMP_STATUS_SOFT_LIMIT_MASK GENMASK(3, 2)
#define BAT_TEMP_STATUS_HOT_SOFT_LIMIT_BIT BIT(3)
#define BAT_TEMP_STATUS_COLD_SOFT_LIMIT_BIT BIT(2)
#define BAT_TEMP_STATUS_TOO_HOT_BIT BIT(1)
#define BAT_TEMP_STATUS_TOO_COLD_BIT BIT(0)
#define BATTERY_CHARGER_STATUS_4 0x0A
#define CHARGE_CURRENT_POST_JEITA_MASK GENMASK(7, 0)
#define BATTERY_CHARGER_STATUS_7 0x0D
#define ENABLE_TRICKLE_BIT BIT(7)
#define ENABLE_PRE_CHARGING_BIT BIT(6)
#define ENABLE_FAST_CHARGING_BIT BIT(5)
#define ENABLE_FULLON_MODE_BIT BIT(4)
#define TOO_COLD_ADC_BIT BIT(3)
#define TOO_HOT_ADC_BIT BIT(2)
#define HOT_SL_ADC_BIT BIT(1)
#define COLD_SL_ADC_BIT BIT(0)
#define CHARGING_ENABLE_CMD 0x42
#define CHARGING_ENABLE_CMD_BIT BIT(0)
#define CHGR_CFG2 0x51
#define CHG_EN_SRC_BIT BIT(7)
#define CHG_EN_POLARITY_BIT BIT(6)
#define PRETOFAST_TRANSITION_CFG_BIT BIT(5)
#define BAT_OV_ECC_BIT BIT(4)
#define I_TERM_BIT BIT(3)
#define AUTO_RECHG_BIT BIT(2)
#define EN_ANALOG_DROP_IN_VBATT_BIT BIT(1)
#define CHARGER_INHIBIT_BIT BIT(0)
#define PRE_CHARGE_CURRENT_CFG 0x60
#define PRE_CHARGE_CURRENT_SETTING_MASK GENMASK(5, 0)
#define FAST_CHARGE_CURRENT_CFG 0x61
#define FAST_CHARGE_CURRENT_SETTING_MASK GENMASK(7, 0)
#define FLOAT_VOLTAGE_CFG 0x70
#define FLOAT_VOLTAGE_SETTING_MASK GENMASK(7, 0)
#define FG_UPDATE_CFG_2_SEL 0x7D
#define SOC_LT_OTG_THRESH_SEL_BIT BIT(3)
#define SOC_LT_CHG_RECHARGE_THRESH_SEL_BIT BIT(2)
#define VBT_LT_CHG_RECHARGE_THRESH_SEL_BIT BIT(1)
#define IBT_LT_CHG_TERM_THRESH_SEL_BIT BIT(0)
#define JEITA_EN_CFG 0x90
#define JEITA_EN_HARDLIMIT_BIT BIT(4)
#define JEITA_EN_HOT_SL_FCV_BIT BIT(3)
#define JEITA_EN_COLD_SL_FCV_BIT BIT(2)
#define JEITA_EN_HOT_SL_CCC_BIT BIT(1)
#define JEITA_EN_COLD_SL_CCC_BIT BIT(0)
#define INT_RT_STS 0x310
#define TYPE_C_CHANGE_RT_STS_BIT BIT(7)
#define USBIN_ICL_CHANGE_RT_STS_BIT BIT(6)
#define USBIN_SOURCE_CHANGE_RT_STS_BIT BIT(5)
#define USBIN_PLUGIN_RT_STS_BIT BIT(4)
#define USBIN_OV_RT_STS_BIT BIT(3)
#define USBIN_UV_RT_STS_BIT BIT(2)
#define USBIN_LT_3P6V_RT_STS_BIT BIT(1)
#define USBIN_COLLAPSE_RT_STS_BIT BIT(0)
#define OTG_CFG 0x153
#define OTG_RESERVED_MASK GENMASK(7, 6)
#define DIS_OTG_ON_TLIM_BIT BIT(5)
#define QUICKSTART_OTG_FASTROLESWAP_BIT BIT(4)
#define INCREASE_DFP_TIME_BIT BIT(3)
#define ENABLE_OTG_IN_DEBUG_MODE_BIT BIT(2)
#define OTG_EN_SRC_CFG_BIT BIT(1)
#define CONCURRENT_MODE_CFG_BIT BIT(0)
#define OTG_ENG_OTG_CFG 0x1C0
#define ENG_BUCKBOOST_HALT1_8_MODE_BIT BIT(0)
#define APSD_STATUS 0x307
#define APSD_STATUS_7_BIT BIT(7)
#define HVDCP_CHECK_TIMEOUT_BIT BIT(6)
#define SLOW_PLUGIN_TIMEOUT_BIT BIT(5)
#define ENUMERATION_DONE_BIT BIT(4)
#define VADP_CHANGE_DONE_AFTER_AUTH_BIT BIT(3)
#define QC_AUTH_DONE_STATUS_BIT BIT(2)
#define QC_CHARGER_BIT BIT(1)
#define APSD_DTC_STATUS_DONE_BIT BIT(0)
#define APSD_RESULT_STATUS 0x308
#define ICL_OVERRIDE_LATCH_BIT BIT(7)
#define APSD_RESULT_STATUS_MASK GENMASK(6, 0)
#define QC_3P0_BIT BIT(6)
#define QC_2P0_BIT BIT(5)
#define FLOAT_CHARGER_BIT BIT(4)
#define DCP_CHARGER_BIT BIT(3)
#define CDP_CHARGER_BIT BIT(2)
#define OCP_CHARGER_BIT BIT(1)
#define SDP_CHARGER_BIT BIT(0)
#define TYPE_C_STATUS_1 0x30B
#define UFP_TYPEC_MASK GENMASK(7, 5)
#define UFP_TYPEC_RDSTD_BIT BIT(7)
#define UFP_TYPEC_RD1P5_BIT BIT(6)
#define UFP_TYPEC_RD3P0_BIT BIT(5)
#define UFP_TYPEC_FMB_255K_BIT BIT(4)
#define UFP_TYPEC_FMB_301K_BIT BIT(3)
#define UFP_TYPEC_FMB_523K_BIT BIT(2)
#define UFP_TYPEC_FMB_619K_BIT BIT(1)
#define UFP_TYPEC_OPEN_OPEN_BIT BIT(0)
#define TYPE_C_STATUS_2 0x30C
#define DFP_RA_OPEN_BIT BIT(7)
#define TIMER_STAGE_BIT BIT(6)
#define EXIT_UFP_MODE_BIT BIT(5)
#define EXIT_DFP_MODE_BIT BIT(4)
#define DFP_TYPEC_MASK GENMASK(3, 0)
#define DFP_RD_OPEN_BIT BIT(3)
#define DFP_RD_RA_VCONN_BIT BIT(2)
#define DFP_RD_RD_BIT BIT(1)
#define DFP_RA_RA_BIT BIT(0)
#define TYPE_C_STATUS_3 0x30D
#define ENABLE_BANDGAP_BIT BIT(7)
#define U_USB_GND_NOVBUS_BIT BIT(6)
#define U_USB_FLOAT_NOVBUS_BIT BIT(5)
#define U_USB_GND_BIT BIT(4)
#define U_USB_FMB1_BIT BIT(3)
#define U_USB_FLOAT1_BIT BIT(2)
#define U_USB_FMB2_BIT BIT(1)
#define U_USB_FLOAT2_BIT BIT(0)
#define TYPE_C_STATUS_4 0x30E
#define UFP_DFP_MODE_STATUS_BIT BIT(7)
#define TYPEC_VBUS_STATUS_BIT BIT(6)
#define TYPEC_VBUS_ERROR_STATUS_BIT BIT(5)
#define TYPEC_DEBOUNCE_DONE_STATUS_BIT BIT(4)
#define TYPEC_UFP_AUDIO_ADAPT_STATUS_BIT BIT(3)
#define TYPEC_VCONN_OVERCURR_STATUS_BIT BIT(2)
#define CC_ORIENTATION_BIT BIT(1)
#define CC_ATTACHED_BIT BIT(0)
#define TYPE_C_STATUS_5 0x30F
#define TRY_SOURCE_FAILED_BIT BIT(6)
#define TRY_SINK_FAILED_BIT BIT(5)
#define TIMER_STAGE_2_BIT BIT(4)
#define TYPEC_LEGACY_CABLE_STATUS_BIT BIT(3)
#define TYPEC_NONCOMP_LEGACY_CABLE_STATUS_BIT BIT(2)
#define TYPEC_TRYSOURCE_DETECT_STATUS_BIT BIT(1)
#define TYPEC_TRYSINK_DETECT_STATUS_BIT BIT(0)
#define CMD_APSD 0x341
#define ICL_OVERRIDE_BIT BIT(1)
#define APSD_RERUN_BIT BIT(0)
#define TYPE_C_CFG 0x358
#define APSD_START_ON_CC_BIT BIT(7)
#define WAIT_FOR_APSD_BIT BIT(6)
#define FACTORY_MODE_DETECTION_EN_BIT BIT(5)
#define FACTORY_MODE_ICL_3A_4A_BIT BIT(4)
#define FACTORY_MODE_DIS_CHGING_CFG_BIT BIT(3)
#define SUSPEND_NON_COMPLIANT_CFG_BIT BIT(2)
#define VCONN_OC_CFG_BIT BIT(1)
#define TYPE_C_OR_U_USB_BIT BIT(0)
#define TYPE_C_CFG_2 0x359
#define TYPE_C_DFP_CURRSRC_MODE_BIT BIT(7)
#define DFP_CC_1P4V_OR_1P6V_BIT BIT(6)
#define VCONN_SOFTSTART_CFG_MASK GENMASK(5, 4)
#define EN_TRY_SOURCE_MODE_BIT BIT(3)
#define USB_FACTORY_MODE_ENABLE_BIT BIT(2)
#define TYPE_C_UFP_MODE_BIT BIT(1)
#define EN_80UA_180UA_CUR_SOURCE_BIT BIT(0)
#define TYPE_C_CFG_3 0x35A
#define TVBUS_DEBOUNCE_BIT BIT(7)
#define TYPEC_LEGACY_CABLE_INT_EN_BIT BIT(6)
#define TYPEC_NONCOMPLIANT_LEGACY_CABLE_INT_EN_B BIT(5)
#define TYPEC_TRYSOURCE_DETECT_INT_EN_BIT BIT(4)
#define TYPEC_TRYSINK_DETECT_INT_EN_BIT BIT(3)
#define EN_TRYSINK_MODE_BIT BIT(2)
#define EN_LEGACY_CABLE_DETECTION_BIT BIT(1)
#define ALLOW_PD_DRING_UFP_TCCDB_BIT BIT(0)
#define USBIN_OPTIONS_1_CFG 0x362
#define CABLE_R_SEL_BIT BIT(7)
#define HVDCP_AUTH_ALG_EN_CFG_BIT BIT(6)
#define HVDCP_AUTONOMOUS_MODE_EN_CFG_BIT BIT(5)
#define INPUT_PRIORITY_BIT BIT(4)
#define AUTO_SRC_DETECT_BIT BIT(3)
#define HVDCP_EN_BIT BIT(2)
#define VADP_INCREMENT_VOLTAGE_LIMIT_BIT BIT(1)
#define VADP_TAPER_TIMER_EN_BIT BIT(0)
#define USBIN_OPTIONS_2_CFG 0x363
#define WIPWR_RST_EUD_CFG_BIT BIT(7)
#define SWITCHER_START_CFG_BIT BIT(6)
#define DCD_TIMEOUT_SEL_BIT BIT(5)
#define OCD_CURRENT_SEL_BIT BIT(4)
#define SLOW_PLUGIN_TIMER_EN_CFG_BIT BIT(3)
#define FLOAT_OPTIONS_MASK GENMASK(2, 0)
#define FLOAT_DIS_CHGING_CFG_BIT BIT(2)
#define SUSPEND_FLOAT_CFG_BIT BIT(1)
#define FORCE_FLOAT_SDP_CFG_BIT BIT(0)
#define TAPER_TIMER_SEL_CFG 0x364
#define TYPEC_SPARE_CFG_BIT BIT(7)
#define TYPEC_DRP_DFP_TIME_CFG_BIT BIT(5)
#define TAPER_TIMER_SEL_MASK GENMASK(1, 0)
#define USBIN_LOAD_CFG 0x365
#define USBIN_OV_CH_LOAD_OPTION_BIT BIT(7)
#define ICL_OVERRIDE_AFTER_APSD_BIT BIT(4)
#define USBIN_ICL_OPTIONS 0x366
#define CFG_USB3P0_SEL_BIT BIT(2)
#define USB51_MODE_BIT BIT(1)
#define USBIN_MODE_CHG_BIT BIT(0)
#define TYPE_C_INTRPT_ENB_SOFTWARE_CTRL 0x368
#define EXIT_SNK_BASED_ON_CC_BIT BIT(7)
#define VCONN_EN_ORIENTATION_BIT BIT(6)
#define TYPEC_VCONN_OVERCURR_INT_EN_BIT BIT(5)
#define VCONN_EN_SRC_BIT BIT(4)
#define VCONN_EN_VALUE_BIT BIT(3)
#define TYPEC_POWER_ROLE_CMD_MASK GENMASK(2, 0)
#define UFP_EN_CMD_BIT BIT(2)
#define DFP_EN_CMD_BIT BIT(1)
#define TYPEC_DISABLE_CMD_BIT BIT(0)
#define USBIN_CURRENT_LIMIT_CFG 0x370
#define USBIN_CURRENT_LIMIT_MASK GENMASK(7, 0)
#define USBIN_AICL_OPTIONS_CFG 0x380
#define SUSPEND_ON_COLLAPSE_USBIN_BIT BIT(7)
#define USBIN_AICL_HDC_EN_BIT BIT(6)
#define USBIN_AICL_START_AT_MAX_BIT BIT(5)
#define USBIN_AICL_RERUN_EN_BIT BIT(4)
#define USBIN_AICL_ADC_EN_BIT BIT(3)
#define USBIN_AICL_EN_BIT BIT(2)
#define USBIN_HV_COLLAPSE_RESPONSE_BIT BIT(1)
#define USBIN_LV_COLLAPSE_RESPONSE_BIT BIT(0)
#define USBIN_5V_AICL_THRESHOLD_CFG 0x381
#define USBIN_5V_AICL_THRESHOLD_CFG_MASK GENMASK(2, 0)
#define USBIN_CONT_AICL_THRESHOLD_CFG 0x384
#define USBIN_CONT_AICL_THRESHOLD_CFG_MASK GENMASK(5, 0)
#define DC_ENG_SSUPPLY_CFG2 0x4C1
#define ENG_SSUPPLY_IVREF_OTG_SS_MASK GENMASK(2, 0)
#define OTG_SS_SLOW 0x3
#define DCIN_AICL_REF_SEL_CFG 0x481
#define DCIN_CONT_AICL_THRESHOLD_CFG_MASK GENMASK(5, 0)
#define WI_PWR_OPTIONS 0x495
#define CHG_OK_BIT BIT(7)
#define WIPWR_UVLO_IRQ_OPT_BIT BIT(6)
#define BUCK_HOLDOFF_ENABLE_BIT BIT(5)
#define CHG_OK_HW_SW_SELECT_BIT BIT(4)
#define WIPWR_RST_ENABLE_BIT BIT(3)
#define DCIN_WIPWR_IRQ_SELECT_BIT BIT(2)
#define AICL_SWITCH_ENABLE_BIT BIT(1)
#define ZIN_ICL_ENABLE_BIT BIT(0)
#define ICL_STATUS 0x607
#define INPUT_CURRENT_LIMIT_MASK GENMASK(7, 0)
#define POWER_PATH_STATUS 0x60B
#define P_PATH_INPUT_SS_DONE_BIT BIT(7)
#define P_PATH_USBIN_SUSPEND_STS_BIT BIT(6)
#define P_PATH_DCIN_SUSPEND_STS_BIT BIT(5)
#define P_PATH_USE_USBIN_BIT BIT(4)
#define P_PATH_USE_DCIN_BIT BIT(3)
#define P_PATH_POWER_PATH_MASK GENMASK(2, 1)
#define P_PATH_VALID_INPUT_POWER_SOURCE_STS_BIT BIT(0)
#define BARK_BITE_WDOG_PET 0x643
#define BARK_BITE_WDOG_PET_BIT BIT(0)
#define WD_CFG 0x651
#define WATCHDOG_TRIGGER_AFP_EN_BIT BIT(7)
#define BARK_WDOG_INT_EN_BIT BIT(6)
#define BITE_WDOG_INT_EN_BIT BIT(5)
#define SFT_AFTER_WDOG_IRQ_MASK GENMASK(4, 3)
#define WDOG_IRQ_SFT_BIT BIT(2)
#define WDOG_TIMER_EN_ON_PLUGIN_BIT BIT(1)
#define WDOG_TIMER_EN_BIT BIT(0)
#define SNARL_BARK_BITE_WD_CFG 0x653
#define BITE_WDOG_DISABLE_CHARGING_CFG_BIT BIT(7)
#define SNARL_WDOG_TIMEOUT_MASK GENMASK(6, 4)
#define BARK_WDOG_TIMEOUT_MASK GENMASK(3, 2)
#define BITE_WDOG_TIMEOUT_MASK GENMASK(1, 0)
#define AICL_RERUN_TIME_CFG 0x661
#define AICL_RERUN_TIME_MASK GENMASK(1, 0)
#define STAT_CFG 0x690
#define STAT_SW_OVERRIDE_VALUE_BIT BIT(7)
#define STAT_SW_OVERRIDE_CFG_BIT BIT(6)
#define STAT_PARALLEL_OFF_DG_CFG_MASK GENMASK(5, 4)
#define STAT_POLARITY_CFG_BIT BIT(3)
#define STAT_PARALLEL_CFG_BIT BIT(2)
#define STAT_FUNCTION_CFG_BIT BIT(1)
#define STAT_IRQ_PULSING_EN_BIT BIT(0)
#define SDP_CURRENT_UA 500000
#define CDP_CURRENT_UA 1500000
#define DCP_CURRENT_UA 1500000
#define CURRENT_MAX_UA DCP_CURRENT_UA
/* pmi8998 registers represent current in increments of 1/40th of an amp */
#define CURRENT_SCALE_FACTOR 25000
/* clang-format on */
enum charger_status {
TRICKLE_CHARGE = 0,
PRE_CHARGE,
FAST_CHARGE,
FULLON_CHARGE,
TAPER_CHARGE,
TERMINATE_CHARGE,
INHIBIT_CHARGE,
DISABLE_CHARGE,
};
struct smb2_register {
u16 addr;
u8 mask;
u8 val;
};
/**
* struct smb2_chip - smb2 chip structure
* @dev: Device reference for power_supply
* @name: The platform device name
* @base: Base address for smb2 registers
* @regmap: Register map
* @batt_info: Battery data from DT
* @status_change_work: Worker to handle plug/unplug events
* @cable_irq: USB plugin IRQ
* @wakeup_enabled: If the cable IRQ will cause a wakeup
* @usb_in_i_chan: USB_IN current measurement channel
* @usb_in_v_chan: USB_IN voltage measurement channel
* @chg_psy: Charger power supply instance
*/
struct smb2_chip {
struct device *dev;
const char *name;
unsigned int base;
struct regmap *regmap;
struct power_supply_battery_info *batt_info;
struct delayed_work status_change_work;
int cable_irq;
bool wakeup_enabled;
struct iio_channel *usb_in_i_chan;
struct iio_channel *usb_in_v_chan;
struct power_supply *chg_psy;
};
static enum power_supply_property smb2_properties[] = {
POWER_SUPPLY_PROP_MANUFACTURER,
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_CURRENT_MAX,
POWER_SUPPLY_PROP_CURRENT_NOW,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_USB_TYPE,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
};
static enum power_supply_usb_type smb2_usb_types[] = {
POWER_SUPPLY_USB_TYPE_UNKNOWN,
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
};
static int smb2_get_prop_usb_online(struct smb2_chip *chip, int *val)
{
unsigned int stat;
int rc;
rc = regmap_read(chip->regmap, chip->base + POWER_PATH_STATUS, &stat);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read power path status: %d\n", rc);
return rc;
}
*val = (stat & P_PATH_USE_USBIN_BIT) &&
(stat & P_PATH_VALID_INPUT_POWER_SOURCE_STS_BIT);
return 0;
}
/*
* Qualcomm "automatic power source detection" aka APSD
* tells us what type of charger we're connected to.
*/
static int smb2_apsd_get_charger_type(struct smb2_chip *chip, int *val)
{
unsigned int apsd_stat, stat;
int usb_online = 0;
int rc;
rc = smb2_get_prop_usb_online(chip, &usb_online);
if (!usb_online) {
*val = POWER_SUPPLY_USB_TYPE_UNKNOWN;
return rc;
}
rc = regmap_read(chip->regmap, chip->base + APSD_STATUS, &apsd_stat);
if (rc < 0) {
dev_err(chip->dev, "Failed to read apsd status, rc = %d", rc);
return rc;
}
if (!(apsd_stat & APSD_DTC_STATUS_DONE_BIT)) {
dev_dbg(chip->dev, "Apsd not ready");
return -EAGAIN;
}
rc = regmap_read(chip->regmap, chip->base + APSD_RESULT_STATUS, &stat);
if (rc < 0) {
dev_err(chip->dev, "Failed to read apsd result, rc = %d", rc);
return rc;
}
stat &= APSD_RESULT_STATUS_MASK;
if (stat & CDP_CHARGER_BIT)
*val = POWER_SUPPLY_USB_TYPE_CDP;
else if (stat & (DCP_CHARGER_BIT | OCP_CHARGER_BIT | FLOAT_CHARGER_BIT))
*val = POWER_SUPPLY_USB_TYPE_DCP;
else /* SDP_CHARGER_BIT (or others) */
*val = POWER_SUPPLY_USB_TYPE_SDP;
return 0;
}
static int smb2_get_prop_status(struct smb2_chip *chip, int *val)
{
unsigned char stat[2];
int usb_online = 0;
int rc;
rc = smb2_get_prop_usb_online(chip, &usb_online);
if (!usb_online) {
*val = POWER_SUPPLY_STATUS_DISCHARGING;
return rc;
}
rc = regmap_bulk_read(chip->regmap,
chip->base + BATTERY_CHARGER_STATUS_1, &stat, 2);
if (rc < 0) {
dev_err(chip->dev, "Failed to read charging status ret=%d\n",
rc);
return rc;
}
if (stat[1] & CHARGER_ERROR_STATUS_BAT_OV_BIT) {
*val = POWER_SUPPLY_STATUS_NOT_CHARGING;
return 0;
}
stat[0] = stat[0] & BATTERY_CHARGER_STATUS_MASK;
switch (stat[0]) {
case TRICKLE_CHARGE:
case PRE_CHARGE:
case FAST_CHARGE:
case FULLON_CHARGE:
case TAPER_CHARGE:
*val = POWER_SUPPLY_STATUS_CHARGING;
return rc;
case DISABLE_CHARGE:
*val = POWER_SUPPLY_STATUS_NOT_CHARGING;
return rc;
case TERMINATE_CHARGE:
*val = POWER_SUPPLY_STATUS_FULL;
return rc;
case INHIBIT_CHARGE:
default:
*val = POWER_SUPPLY_STATUS_UNKNOWN;
return rc;
}
}
static inline int smb2_get_current_limit(struct smb2_chip *chip,
unsigned int *val)
{
int rc = regmap_read(chip->regmap, chip->base + ICL_STATUS, val);
if (rc >= 0)
*val *= CURRENT_SCALE_FACTOR;
return rc;
}
static int smb2_set_current_limit(struct smb2_chip *chip, unsigned int val)
{
unsigned char val_raw;
if (val > 4800000) {
dev_err(chip->dev,
"Can't set current limit higher than 4800000uA");
return -EINVAL;
}
val_raw = val / CURRENT_SCALE_FACTOR;
return regmap_write(chip->regmap, chip->base + USBIN_CURRENT_LIMIT_CFG,
val_raw);
}
static void smb2_status_change_work(struct work_struct *work)
{
unsigned int charger_type, current_ua;
int usb_online, count, rc;
struct smb2_chip *chip;
chip = container_of(work, struct smb2_chip, status_change_work.work);
smb2_get_prop_usb_online(chip, &usb_online);
if (!usb_online)
return;
for (count = 0; count < 3; count++) {
dev_dbg(chip->dev, "get charger type retry %d\n", count);
rc = smb2_apsd_get_charger_type(chip, &charger_type);
if (rc != -EAGAIN)
break;
msleep(100);
}
if (rc < 0 && rc != -EAGAIN) {
dev_err(chip->dev, "get charger type failed: %d\n", rc);
return;
}
if (rc < 0) {
rc = regmap_update_bits(chip->regmap, chip->base + CMD_APSD,
APSD_RERUN_BIT, APSD_RERUN_BIT);
schedule_delayed_work(&chip->status_change_work,
msecs_to_jiffies(1000));
dev_dbg(chip->dev, "get charger type failed, rerun apsd\n");
return;
}
switch (charger_type) {
case POWER_SUPPLY_USB_TYPE_CDP:
current_ua = CDP_CURRENT_UA;
break;
case POWER_SUPPLY_USB_TYPE_DCP:
current_ua = DCP_CURRENT_UA;
break;
case POWER_SUPPLY_USB_TYPE_SDP:
default:
current_ua = SDP_CURRENT_UA;
break;
}
smb2_set_current_limit(chip, current_ua);
power_supply_changed(chip->chg_psy);
}
static int smb2_get_iio_chan(struct smb2_chip *chip, struct iio_channel *chan,
int *val)
{
int rc;
union power_supply_propval status;
rc = power_supply_get_property(chip->chg_psy, POWER_SUPPLY_PROP_STATUS,
&status);
if (rc < 0 || status.intval != POWER_SUPPLY_STATUS_CHARGING) {
*val = 0;
return 0;
}
if (IS_ERR(chan)) {
dev_err(chip->dev, "Failed to chan, err = %li", PTR_ERR(chan));
return PTR_ERR(chan);
}
return iio_read_channel_processed(chan, val);
}
static int smb2_get_prop_health(struct smb2_chip *chip, int *val)
{
int rc;
unsigned int stat;
rc = regmap_read(chip->regmap, chip->base + BATTERY_CHARGER_STATUS_2,
&stat);
if (rc < 0) {
dev_err(chip->dev, "Couldn't read charger status rc=%d\n", rc);
return rc;
}
switch (stat) {
case CHARGER_ERROR_STATUS_BAT_OV_BIT:
*val = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
return 0;
case BAT_TEMP_STATUS_TOO_COLD_BIT:
*val = POWER_SUPPLY_HEALTH_COLD;
return 0;
case BAT_TEMP_STATUS_TOO_HOT_BIT:
*val = POWER_SUPPLY_HEALTH_OVERHEAT;
return 0;
case BAT_TEMP_STATUS_COLD_SOFT_LIMIT_BIT:
*val = POWER_SUPPLY_HEALTH_COOL;
return 0;
case BAT_TEMP_STATUS_HOT_SOFT_LIMIT_BIT:
*val = POWER_SUPPLY_HEALTH_WARM;
return 0;
default:
*val = POWER_SUPPLY_HEALTH_GOOD;
return 0;
}
}
static int smb2_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct smb2_chip *chip = power_supply_get_drvdata(psy);
switch (psp) {
case POWER_SUPPLY_PROP_MANUFACTURER:
val->strval = "Qualcomm";
return 0;
case POWER_SUPPLY_PROP_MODEL_NAME:
val->strval = chip->name;
return 0;
case POWER_SUPPLY_PROP_CURRENT_MAX:
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
return smb2_get_current_limit(chip, &val->intval);
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX:
val->intval = DCP_CURRENT_UA;
return 0;
case POWER_SUPPLY_PROP_CURRENT_NOW:
return smb2_get_iio_chan(chip, chip->usb_in_i_chan,
&val->intval);
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
return smb2_get_iio_chan(chip, chip->usb_in_v_chan,
&val->intval);
case POWER_SUPPLY_PROP_ONLINE:
return smb2_get_prop_usb_online(chip, &val->intval);
case POWER_SUPPLY_PROP_STATUS:
return smb2_get_prop_status(chip, &val->intval);
case POWER_SUPPLY_PROP_HEALTH:
return smb2_get_prop_health(chip, &val->intval);
case POWER_SUPPLY_PROP_USB_TYPE:
return smb2_apsd_get_charger_type(chip, &val->intval);
default:
dev_err(chip->dev, "invalid property: %d\n", psp);
return -EINVAL;
}
}
static int smb2_set_property(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val)
{
struct smb2_chip *chip = power_supply_get_drvdata(psy);
switch (psp) {
case POWER_SUPPLY_PROP_CURRENT_MAX:
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
return smb2_set_current_limit(chip, val->intval);
default:
dev_err(chip->dev, "No setter for property: %d\n", psp);
return -EINVAL;
}
}
static int smb2_property_is_writable(struct power_supply *psy,
enum power_supply_property psp)
{
switch (psp) {
case POWER_SUPPLY_PROP_CURRENT_MAX:
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
return 1;
default:
return 0;
}
}
static irqreturn_t smb2_handle_batt_overvoltage(int irq, void *data)
{
struct smb2_chip *chip = data;
unsigned int status;
regmap_read(chip->regmap, chip->base + BATTERY_CHARGER_STATUS_2,
&status);
if (status & CHARGER_ERROR_STATUS_BAT_OV_BIT) {
/* The hardware stops charging automatically */
dev_err(chip->dev, "battery overvoltage detected\n");
power_supply_changed(chip->chg_psy);
}
return IRQ_HANDLED;
}
static irqreturn_t smb2_handle_usb_plugin(int irq, void *data)
{
struct smb2_chip *chip = data;
power_supply_changed(chip->chg_psy);
schedule_delayed_work(&chip->status_change_work,
msecs_to_jiffies(1500));
return IRQ_HANDLED;
}
static irqreturn_t smb2_handle_usb_icl_change(int irq, void *data)
{
struct smb2_chip *chip = data;
power_supply_changed(chip->chg_psy);
return IRQ_HANDLED;
}
static irqreturn_t smb2_handle_wdog_bark(int irq, void *data)
{
struct smb2_chip *chip = data;
int rc;
power_supply_changed(chip->chg_psy);
rc = regmap_write(chip->regmap, BARK_BITE_WDOG_PET,
BARK_BITE_WDOG_PET_BIT);
if (rc < 0)
dev_err(chip->dev, "Couldn't pet the dog rc=%d\n", rc);
return IRQ_HANDLED;
}
static const struct power_supply_desc smb2_psy_desc = {
.name = "pmi8998_charger",
.type = POWER_SUPPLY_TYPE_USB,
.usb_types = smb2_usb_types,
.num_usb_types = ARRAY_SIZE(smb2_usb_types),
.properties = smb2_properties,
.num_properties = ARRAY_SIZE(smb2_properties),
.get_property = smb2_get_property,
.set_property = smb2_set_property,
.property_is_writeable = smb2_property_is_writable,
};
/* Init sequence derived from vendor downstream driver */
static const struct smb2_register smb2_init_seq[] = {
{ .addr = AICL_RERUN_TIME_CFG, .mask = AICL_RERUN_TIME_MASK, .val = 0 },
/*
* By default configure us as an upstream facing port
* FIXME: This will be handled by the type-c driver
*/
{ .addr = TYPE_C_INTRPT_ENB_SOFTWARE_CTRL,
.mask = TYPEC_POWER_ROLE_CMD_MASK | VCONN_EN_SRC_BIT |
VCONN_EN_VALUE_BIT,
.val = VCONN_EN_SRC_BIT },
/*
* Disable Type-C factory mode and stay in Attached.SRC state when VCONN
* over-current happens
*/
{ .addr = TYPE_C_CFG,
.mask = FACTORY_MODE_DETECTION_EN_BIT | VCONN_OC_CFG_BIT,
.val = 0 },
/* Configure VBUS for software control */
{ .addr = OTG_CFG, .mask = OTG_EN_SRC_CFG_BIT, .val = 0 },
/*
* Use VBAT to determine the recharge threshold when battery is full
* rather than the state of charge.
*/
{ .addr = FG_UPDATE_CFG_2_SEL,
.mask = SOC_LT_CHG_RECHARGE_THRESH_SEL_BIT |
VBT_LT_CHG_RECHARGE_THRESH_SEL_BIT,
.val = VBT_LT_CHG_RECHARGE_THRESH_SEL_BIT },
/* Enable charging */
{ .addr = USBIN_OPTIONS_1_CFG, .mask = HVDCP_EN_BIT, .val = 0 },
{ .addr = CHARGING_ENABLE_CMD,
.mask = CHARGING_ENABLE_CMD_BIT,
.val = CHARGING_ENABLE_CMD_BIT },
/*
* Match downstream defaults
* CHG_EN_SRC_BIT - charger enable is controlled by software
* CHG_EN_POLARITY_BIT - polarity of charge enable pin when in HW control
* pulled low on OnePlus 6 and SHIFT6mq
* PRETOFAST_TRANSITION_CFG_BIT -
* BAT_OV_ECC_BIT -
* I_TERM_BIT - Current termination ?? 0 = enabled
* AUTO_RECHG_BIT - Enable automatic recharge when battery is full
* 0 = enabled
* EN_ANALOG_DROP_IN_VBATT_BIT
* CHARGER_INHIBIT_BIT - Inhibit charging based on battery voltage
* instead of ??
*/
{ .addr = CHGR_CFG2,
.mask = CHG_EN_SRC_BIT | CHG_EN_POLARITY_BIT |
PRETOFAST_TRANSITION_CFG_BIT | BAT_OV_ECC_BIT | I_TERM_BIT |
AUTO_RECHG_BIT | EN_ANALOG_DROP_IN_VBATT_BIT |
CHARGER_INHIBIT_BIT,
.val = CHARGER_INHIBIT_BIT },
/* STAT pin software override, match downstream. Parallell charging? */
{ .addr = STAT_CFG,
.mask = STAT_SW_OVERRIDE_CFG_BIT,
.val = STAT_SW_OVERRIDE_CFG_BIT },
/* Set the default SDP charger type to a 500ma USB 2.0 port */
{ .addr = USBIN_ICL_OPTIONS,
.mask = USB51_MODE_BIT | USBIN_MODE_CHG_BIT,
.val = USB51_MODE_BIT },
/* Disable watchdog */
{ .addr = SNARL_BARK_BITE_WD_CFG, .mask = 0xff, .val = 0 },
{ .addr = WD_CFG,
.mask = WATCHDOG_TRIGGER_AFP_EN_BIT | WDOG_TIMER_EN_ON_PLUGIN_BIT |
BARK_WDOG_INT_EN_BIT,
.val = 0 },
/* These bits aren't documented anywhere */
{ .addr = USBIN_5V_AICL_THRESHOLD_CFG,
.mask = USBIN_5V_AICL_THRESHOLD_CFG_MASK,
.val = 0x3 },
{ .addr = USBIN_CONT_AICL_THRESHOLD_CFG,
.mask = USBIN_CONT_AICL_THRESHOLD_CFG_MASK,
.val = 0x3 },
/*
* Enable Automatic Input Current Limit, this will slowly ramp up the current
* When connected to a wall charger, and automatically stop when it detects
* the charger current limit (voltage drop?) or it reaches the programmed limit.
*/
{ .addr = USBIN_AICL_OPTIONS_CFG,
.mask = USBIN_AICL_START_AT_MAX_BIT | USBIN_AICL_ADC_EN_BIT |
USBIN_AICL_EN_BIT | SUSPEND_ON_COLLAPSE_USBIN_BIT |
USBIN_HV_COLLAPSE_RESPONSE_BIT |
USBIN_LV_COLLAPSE_RESPONSE_BIT,
.val = USBIN_HV_COLLAPSE_RESPONSE_BIT |
USBIN_LV_COLLAPSE_RESPONSE_BIT | USBIN_AICL_EN_BIT },
/*
* Set pre charge current to default, the OnePlus 6 bootloader
* sets this very conservatively.
*/
{ .addr = PRE_CHARGE_CURRENT_CFG,
.mask = PRE_CHARGE_CURRENT_SETTING_MASK,
.val = 500000 / CURRENT_SCALE_FACTOR },
/*
* This overrides all of the current limit options exposed to userspace
* and prevents the device from pulling more than ~1A. This is done
* to minimise potential fire hazard risks.
*/
{ .addr = FAST_CHARGE_CURRENT_CFG,
.mask = FAST_CHARGE_CURRENT_SETTING_MASK,
.val = 1000000 / CURRENT_SCALE_FACTOR },
};
static int smb2_init_hw(struct smb2_chip *chip)
{
int rc, i;
for (i = 0; i < ARRAY_SIZE(smb2_init_seq); i++) {
dev_dbg(chip->dev, "%d: Writing 0x%02x to 0x%02x\n", i,
smb2_init_seq[i].val, smb2_init_seq[i].addr);
rc = regmap_update_bits(chip->regmap,
chip->base + smb2_init_seq[i].addr,
smb2_init_seq[i].mask,
smb2_init_seq[i].val);
if (rc < 0)
return dev_err_probe(chip->dev, rc,
"%s: init command %d failed\n",
__func__, i);
}
return 0;
}
static int smb2_init_irq(struct smb2_chip *chip, int *irq, const char *name,
irqreturn_t (*handler)(int irq, void *data))
{
int irqnum;
int rc;
irqnum = platform_get_irq_byname(to_platform_device(chip->dev), name);
if (irqnum < 0)
return dev_err_probe(chip->dev, irqnum,
"Couldn't get irq %s byname\n", name);
rc = devm_request_threaded_irq(chip->dev, irqnum, NULL, handler,
IRQF_ONESHOT, name, chip);
if (rc < 0)
return dev_err_probe(chip->dev, rc, "Couldn't request irq %s\n",
name);
if (irq)
*irq = irqnum;
return 0;
}
static int smb2_probe(struct platform_device *pdev)
{
struct power_supply_config supply_config = {};
struct power_supply_desc *desc;
struct smb2_chip *chip;
int rc, irq;
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
return -ENOMEM;
chip->dev = &pdev->dev;
chip->name = pdev->name;
chip->regmap = dev_get_regmap(pdev->dev.parent, NULL);
if (!chip->regmap)
return dev_err_probe(chip->dev, -ENODEV,
"failed to locate the regmap\n");
rc = device_property_read_u32(chip->dev, "reg", &chip->base);
if (rc < 0)
return dev_err_probe(chip->dev, rc,
"Couldn't read base address\n");
chip->usb_in_v_chan = devm_iio_channel_get(chip->dev, "usbin_v");
if (IS_ERR(chip->usb_in_v_chan))
return dev_err_probe(chip->dev, PTR_ERR(chip->usb_in_v_chan),
"Couldn't get usbin_v IIO channel\n");
chip->usb_in_i_chan = devm_iio_channel_get(chip->dev, "usbin_i");
if (IS_ERR(chip->usb_in_i_chan)) {
return dev_err_probe(chip->dev, PTR_ERR(chip->usb_in_i_chan),
"Couldn't get usbin_i IIO channel\n");
}
rc = smb2_init_hw(chip);
if (rc < 0)
return rc;
supply_config.drv_data = chip;
supply_config.of_node = pdev->dev.of_node;
desc = devm_kzalloc(chip->dev, sizeof(smb2_psy_desc), GFP_KERNEL);
memcpy(desc, &smb2_psy_desc, sizeof(smb2_psy_desc));
desc->name =
devm_kasprintf(chip->dev, GFP_KERNEL, "%s-charger",
(const char *)device_get_match_data(chip->dev));
chip->chg_psy =
devm_power_supply_register(chip->dev, desc, &supply_config);
if (IS_ERR(chip->chg_psy))
return dev_err_probe(chip->dev, PTR_ERR(chip->chg_psy),
"failed to register power supply\n");
rc = power_supply_get_battery_info(chip->chg_psy, &chip->batt_info);
if (rc)
return dev_err_probe(chip->dev, rc,
"Failed to get battery info\n");
rc = devm_delayed_work_autocancel(chip->dev, &chip->status_change_work,
smb2_status_change_work);
if (rc)
return dev_err_probe(chip->dev, rc,
"Failed to init status change work\n");
rc = (chip->batt_info->voltage_max_design_uv - 3487500) / 7500 + 1;
rc = regmap_update_bits(chip->regmap, chip->base + FLOAT_VOLTAGE_CFG,
FLOAT_VOLTAGE_SETTING_MASK, rc);
if (rc < 0)
return dev_err_probe(chip->dev, rc, "Couldn't set vbat max\n");
rc = smb2_init_irq(chip, &irq, "bat-ov", smb2_handle_batt_overvoltage);
if (rc < 0)
return rc;
rc = smb2_init_irq(chip, &chip->cable_irq, "usb-plugin",
smb2_handle_usb_plugin);
if (rc < 0)
return rc;
rc = smb2_init_irq(chip, &irq, "usbin-icl-change",
smb2_handle_usb_icl_change);
if (rc < 0)
return rc;
rc = smb2_init_irq(chip, &irq, "wdog-bark", smb2_handle_wdog_bark);
if (rc < 0)
return rc;
rc = dev_pm_set_wake_irq(chip->dev, chip->cable_irq);
if (rc < 0)
return dev_err_probe(chip->dev, rc, "Couldn't set wake irq\n");
platform_set_drvdata(pdev, chip);
/* Initialise charger state */
schedule_delayed_work(&chip->status_change_work, 0);
return 0;
}
static const struct of_device_id smb2_match_id_table[] = {
{ .compatible = "qcom,pmi8998-charger", .data = "pmi8998" },
{ .compatible = "qcom,pm660-charger", .data = "pm660" },
{ /* sentinal */ }
};
MODULE_DEVICE_TABLE(of, smb2_match_id_table);
static struct platform_driver qcom_spmi_smb2 = {
.probe = smb2_probe,
.driver = {
.name = "qcom-pmi8998/pm660-charger",
.of_match_table = smb2_match_id_table,
},
};
module_platform_driver(qcom_spmi_smb2);
MODULE_AUTHOR("Caleb Connolly <caleb.connolly@linaro.org>");
MODULE_DESCRIPTION("Qualcomm SMB2 Charger Driver");
MODULE_LICENSE("GPL");
...@@ -1134,7 +1134,7 @@ static int rk817_charger_probe(struct platform_device *pdev) ...@@ -1134,7 +1134,7 @@ static int rk817_charger_probe(struct platform_device *pdev)
&bat_info); &bat_info);
if (ret) { if (ret) {
return dev_err_probe(dev, ret, return dev_err_probe(dev, ret,
"Unable to get battery info: %d\n", ret); "Unable to get battery info\n");
} }
if ((bat_info->charge_full_design_uah <= 0) || if ((bat_info->charge_full_design_uah <= 0) ||
......
...@@ -196,7 +196,7 @@ static struct i2c_driver rt5033_battery_driver = { ...@@ -196,7 +196,7 @@ static struct i2c_driver rt5033_battery_driver = {
.name = "rt5033-battery", .name = "rt5033-battery",
.of_match_table = rt5033_battery_of_match, .of_match_table = rt5033_battery_of_match,
}, },
.probe_new = rt5033_battery_probe, .probe = rt5033_battery_probe,
.remove = rt5033_battery_remove, .remove = rt5033_battery_remove,
.id_table = rt5033_battery_id, .id_table = rt5033_battery_id,
}; };
......
...@@ -1737,7 +1737,7 @@ MODULE_DEVICE_TABLE(acpi, rt9455_i2c_acpi_match); ...@@ -1737,7 +1737,7 @@ MODULE_DEVICE_TABLE(acpi, rt9455_i2c_acpi_match);
#endif #endif
static struct i2c_driver rt9455_driver = { static struct i2c_driver rt9455_driver = {
.probe_new = rt9455_probe, .probe = rt9455_probe,
.remove = rt9455_remove, .remove = rt9455_remove,
.id_table = rt9455_i2c_id_table, .id_table = rt9455_i2c_id_table,
.driver = { .driver = {
......
...@@ -1192,7 +1192,7 @@ static int rt9467_charger_probe(struct i2c_client *i2c) ...@@ -1192,7 +1192,7 @@ static int rt9467_charger_probe(struct i2c_client *i2c)
i2c_set_clientdata(i2c, data); i2c_set_clientdata(i2c, data);
/* Default pull charge enable gpio to make 'CHG_EN' by SW control only */ /* Default pull charge enable gpio to make 'CHG_EN' by SW control only */
ceb_gpio = devm_gpiod_get_optional(dev, "charge-enable", GPIOD_OUT_LOW); ceb_gpio = devm_gpiod_get_optional(dev, "charge-enable", GPIOD_OUT_HIGH);
if (IS_ERR(ceb_gpio)) if (IS_ERR(ceb_gpio))
return dev_err_probe(dev, PTR_ERR(ceb_gpio), return dev_err_probe(dev, PTR_ERR(ceb_gpio),
"Failed to config charge enable gpio\n"); "Failed to config charge enable gpio\n");
...@@ -1272,7 +1272,7 @@ static struct i2c_driver rt9467_charger_driver = { ...@@ -1272,7 +1272,7 @@ static struct i2c_driver rt9467_charger_driver = {
.name = "rt9467-charger", .name = "rt9467-charger",
.of_match_table = rt9467_charger_of_match_table, .of_match_table = rt9467_charger_of_match_table,
}, },
.probe_new = rt9467_charger_probe, .probe = rt9467_charger_probe,
}; };
module_i2c_driver(rt9467_charger_driver); module_i2c_driver(rt9467_charger_driver);
......
...@@ -919,7 +919,7 @@ static struct i2c_driver rt9471_driver = { ...@@ -919,7 +919,7 @@ static struct i2c_driver rt9471_driver = {
.name = "rt9471", .name = "rt9471",
.of_match_table = rt9471_of_device_id, .of_match_table = rt9471_of_device_id,
}, },
.probe_new = rt9471_probe, .probe = rt9471_probe,
.shutdown = rt9471_shutdown, .shutdown = rt9471_shutdown,
}; };
module_i2c_driver(rt9471_driver); module_i2c_driver(rt9471_driver);
......
...@@ -1275,7 +1275,7 @@ static const struct of_device_id sbs_dt_ids[] = { ...@@ -1275,7 +1275,7 @@ static const struct of_device_id sbs_dt_ids[] = {
MODULE_DEVICE_TABLE(of, sbs_dt_ids); MODULE_DEVICE_TABLE(of, sbs_dt_ids);
static struct i2c_driver sbs_battery_driver = { static struct i2c_driver sbs_battery_driver = {
.probe_new = sbs_probe, .probe = sbs_probe,
.alert = sbs_alert, .alert = sbs_alert,
.id_table = sbs_id, .id_table = sbs_id,
.driver = { .driver = {
......
...@@ -240,7 +240,7 @@ static const struct i2c_device_id sbs_id[] = { ...@@ -240,7 +240,7 @@ static const struct i2c_device_id sbs_id[] = {
MODULE_DEVICE_TABLE(i2c, sbs_id); MODULE_DEVICE_TABLE(i2c, sbs_id);
static struct i2c_driver sbs_driver = { static struct i2c_driver sbs_driver = {
.probe_new = sbs_probe, .probe = sbs_probe,
.id_table = sbs_id, .id_table = sbs_id,
.driver = { .driver = {
.name = "sbs-charger", .name = "sbs-charger",
......
...@@ -409,7 +409,7 @@ static struct i2c_driver sbsm_driver = { ...@@ -409,7 +409,7 @@ static struct i2c_driver sbsm_driver = {
.name = "sbsm", .name = "sbsm",
.of_match_table = of_match_ptr(sbsm_dt_ids), .of_match_table = of_match_ptr(sbsm_dt_ids),
}, },
.probe_new = sbsm_probe, .probe = sbsm_probe,
.alert = sbsm_alert, .alert = sbsm_alert,
.id_table = sbsm_ids .id_table = sbsm_ids
}; };
......
...@@ -1629,7 +1629,7 @@ static struct i2c_driver smb347_driver = { ...@@ -1629,7 +1629,7 @@ static struct i2c_driver smb347_driver = {
.name = "smb347", .name = "smb347",
.of_match_table = smb3xx_of_match, .of_match_table = smb3xx_of_match,
}, },
.probe_new = smb347_probe, .probe = smb347_probe,
.remove = smb347_remove, .remove = smb347_remove,
.shutdown = smb347_shutdown, .shutdown = smb347_shutdown,
.id_table = smb347_id, .id_table = smb347_id,
......
...@@ -168,19 +168,13 @@ static int twl4030_madc_bat_get_property(struct power_supply *psy, ...@@ -168,19 +168,13 @@ static int twl4030_madc_bat_get_property(struct power_supply *psy,
return 0; return 0;
} }
static void twl4030_madc_bat_ext_changed(struct power_supply *psy)
{
power_supply_changed(psy);
}
static const struct power_supply_desc twl4030_madc_bat_desc = { static const struct power_supply_desc twl4030_madc_bat_desc = {
.name = "twl4030_battery", .name = "twl4030_battery",
.type = POWER_SUPPLY_TYPE_BATTERY, .type = POWER_SUPPLY_TYPE_BATTERY,
.properties = twl4030_madc_bat_props, .properties = twl4030_madc_bat_props,
.num_properties = ARRAY_SIZE(twl4030_madc_bat_props), .num_properties = ARRAY_SIZE(twl4030_madc_bat_props),
.get_property = twl4030_madc_bat_get_property, .get_property = twl4030_madc_bat_get_property,
.external_power_changed = twl4030_madc_bat_ext_changed, .external_power_changed = power_supply_changed,
}; };
static int twl4030_cmp(const void *a, const void *b) static int twl4030_cmp(const void *a, const void *b)
......
...@@ -680,7 +680,7 @@ static struct i2c_driver ucs1002_driver = { ...@@ -680,7 +680,7 @@ static struct i2c_driver ucs1002_driver = {
.name = "ucs1002", .name = "ucs1002",
.of_match_table = ucs1002_of_match, .of_match_table = ucs1002_of_match,
}, },
.probe_new = ucs1002_probe, .probe = ucs1002_probe,
}; };
module_i2c_driver(ucs1002_driver); module_i2c_driver(ucs1002_driver);
......
...@@ -476,7 +476,7 @@ static struct i2c_driver ug3105_i2c_driver = { ...@@ -476,7 +476,7 @@ static struct i2c_driver ug3105_i2c_driver = {
.name = "ug3105", .name = "ug3105",
.pm = &ug3105_pm_ops, .pm = &ug3105_pm_ops,
}, },
.probe_new = ug3105_probe, .probe = ug3105_probe,
.id_table = ug3105_id, .id_table = ug3105_id,
}; };
module_i2c_driver(ug3105_i2c_driver); module_i2c_driver(ug3105_i2c_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment