dt-bindings: power: Add the bq25790 dt bindings
Subsystems (2)
PATCH v3 1/2 dt-bindings: power: Add the bq25790 dt bindings
Add the bindings for the bq25790.
--- .../bindings/power/supply/bq25790.yaml | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/bq25790.yaml
Documentation/devicetree/bindings/power/supply/bq25790.yaml new file +95 -0
@@ -0,0 +1,95 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/bq25790.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: TI BQ25790 Switch Mode Buck-Boost Charger + +maintainers: + - Dan Murphy <[email protected]> + +description: | + BQ25790 is a highly integrated switch-mode buck-boost charger for 1-4 cell + Li-ion batteries and Li-polymer batteries. The device charges a battery from a + wide range of input sources including legacy USB adapters to high voltage USB + PD adapters and traditional barrel adapters. + +allOf: + - $ref: power-supply.yaml# + +properties: + compatible: + enum: + - ti,bq25790 + - ti,bq25792 + + reg: + maxItems: 1 + + ti,watchdog-timeout-ms: + default: 0 + description: | + Watchdog timer in milli seconds. 0 (default) disables the watchdog. + minimum: 0 + maximum: 160000 + enum: [ 0, 500, 1000, 2000, 20000, 40000, 80000, 160000] + + input-voltage-limit-microvolt: + description: | + Minimum input voltage limit in micro volts with a 100000 micro volt step. + minimum: 3600000 + maximum: 22000000 + + input-current-limit-microamp: + description: | + Maximum input current limit in micro amps with a 100000 micro amp step. + minimum: 100000 + maximum: 3300000 + + monitored-battery: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle to the battery node being monitored + + interrupts: + maxItems: 1 + description: | + Interrupt sends an active low, 256 μs pulse to host to report the charger + device status and faults. + +required: + - compatible + - reg + - monitored-battery + +unevaluatedProperties: false + +examples: + - | + bat: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <2000000>; + constant-charge-voltage-max-microvolt = <4200000>; + precharge-current-microamp = <160000>; + charge-term-current-microamp = <160000>; + }; + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/irq.h> + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + bq25790: charger@6b { + compatible = "ti,bq25790"; + reg = <0x6b>; + interrupt-parent = <&gpio1>; + interrupts = <16 IRQ_TYPE_EDGE_FALLING>; + ti,watchdog-timeout-ms = <2000>; + input-current-limit-microamp = <3000000>; + input-voltage-limit-microvolt = <4500000>; + monitored-battery = <&bat>; + }; + }; + +...
Signature · 1 line
2.28.0.585.ge1cfff676549
PATCH v3 2/2 power: supply: bq25790: Introduce the BQ25790 charger driver
BQ25790 is a highly integrated switch-mode buck-boost charger for 1-4 cell Li-ion battery and Li-polymer battery.
--- drivers/power/supply/Kconfig | 8 + drivers/power/supply/Makefile | 1 + drivers/power/supply/bq25790_charger.c | 1123 ++++++++++++++++++++++++ drivers/power/supply/bq25790_charger.h | 150 ++++ 4 files changed, 1282 insertions(+) create mode 100644 drivers/power/supply/bq25790_charger.c create mode 100644 drivers/power/supply/bq25790_charger.h
drivers/power/supply/Kconfig +8 -0
@@ -628,6 +628,14 @@ config CHARGER_BQ2515X rail, ADC for battery and system monitoring, and push-button controller. +config CHARGER_BQ25790 + tristate "TI BQ25790 battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ25790 battery charger. + config CHARGER_BQ25890 tristate "TI BQ25890 battery charger driver" depends on I2C
drivers/power/supply/Makefile +1 -0
@@ -83,6 +83,7 @@ obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o obj-$(CONFIG_CHARGER_BQ2515X) += bq2515x_charger.o +obj-$(CONFIG_CHARGER_BQ25790) += bq25790_charger.o obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_CHARGER_BQ25980) += bq25980_charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o
drivers/power/supply/bq25790_charger.c new file +1123 -0
1,123 lines not on this page · raw message
drivers/power/supply/bq25790_charger.h new file +150 -0
150 lines not on this page · raw message
Signature · 1 line
2.28.0.585.ge1cfff676549
kernel test robot
build botRe: [PATCH v3 2/2] power: supply: bq25790: Introduce the BQ25790 charger driver
I love your patch! Perhaps something to improve:
Hi Dan,
I love your patch! Perhaps something to improve:
[auto build test WARNING on power-supply/for-next]
[also build test WARNING on linus/master v5.9-rc8 next-20201008] [cannot apply to linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Dan-Murphy/dt-bindings-power-Add-the-bq25790-dt-bindings/20201008-234450 base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next config: riscv-randconfig-r031-20201009 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 8da0df3d6dcc0dd42740be60b0da4ec201190904)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/bc435a97ea513a3f4baa45b167b623a82187f9d3
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Dan-Murphy/dt-bindings-power-Add-the-bq25790-dt-bindings/20201008-234450 git checkout bc435a97ea513a3f4baa45b167b623a82187f9d3
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/power/supply/bq25790_charger.c:624:21: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
if (state.fault_1 && (BQ25790_OTG_OVP | BQ25790_VSYS_OVP))
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/power/supply/bq25790_charger.c:624:21: note: use '&' for a bitwise operation
if (state.fault_1 && (BQ25790_OTG_OVP | BQ25790_VSYS_OVP))
^~
&
drivers/power/supply/bq25790_charger.c:624:21: note: remove constant to silence this warning
if (state.fault_1 && (BQ25790_OTG_OVP | BQ25790_VSYS_OVP))
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/power/supply/bq25790_charger.c:1102:36: warning: unused variable 'bq25790_acpi_match' [-Wunused-const-variable]
static const struct acpi_device_id bq25790_acpi_match[] = {
^2 warnings generated.
vim +624 drivers/power/supply/bq25790_charger.c
537
538 static int bq25790_get_property(struct power_supply *psy,
539 enum power_supply_property psp,
540 union power_supply_propval *val)
541 {
542 struct bq25790_device *bq = power_supply_get_drvdata(psy);
543 struct bq25790_state state;
544 int ret = 0;
545
546 mutex_lock(&bq->lock);
547 ret = bq25790_get_state(bq, &state);
548 mutex_unlock(&bq->lock);
549 if (ret)
550 return ret;
551
552 switch (psp) {
553 case POWER_SUPPLY_PROP_STATUS:
554 if (!state.chrg_type || (state.chrg_type == BQ25790_OTG_MODE))
555 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
556 else if (!state.chrg_status)
557 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
558 else if (state.chrg_status == BQ25790_TERM_CHRG)
559 val->intval = POWER_SUPPLY_STATUS_FULL;
560 else
561 val->intval = POWER_SUPPLY_STATUS_CHARGING;
562 break;
563 case POWER_SUPPLY_PROP_CHARGE_TYPE:
564 switch (state.chrg_status) {
565 case BQ25790_TRICKLE_CHRG:
566 val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
567 break;
568 case BQ25790_PRECHRG:
569 val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
570 break;
571 case BQ25790_FAST_CHRG:
572 val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST;
573 break;
574 case BQ25790_TAPER_CHRG:
575 val->intval = POWER_SUPPLY_CHARGE_TYPE_STANDARD;
576 break;
577 case BQ25790_TOP_OFF_CHRG:
578 val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
579 break;
580 case BQ25790_NOT_CHRGING:
581 val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE;
582 break;
583 default:
584 val->intval = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
585 }
586 break;
587 case POWER_SUPPLY_PROP_MANUFACTURER:
588 val->strval = BQ25790_MANUFACTURER;
589 break;
590
591 case POWER_SUPPLY_PROP_MODEL_NAME:
592 val->strval = BQ25790_NAME;
593 break;
594
595 case POWER_SUPPLY_PROP_ONLINE:
596 val->intval = state.online;
597 break;
598 case POWER_SUPPLY_PROP_USB_TYPE:
599 if (!state.chrg_type) {
600 val->intval = POWER_SUPPLY_USB_TYPE_UNKNOWN;
601 break;
602 }
603 switch (state.chrg_type) {
604 case BQ25790_USB_SDP:
605 val->intval = POWER_SUPPLY_USB_TYPE_SDP;
606 break;
607 case BQ25790_USB_CDP:
608 val->intval = POWER_SUPPLY_USB_TYPE_CDP;
609 break;
610 case BQ25790_USB_DCP:
611 val->intval = POWER_SUPPLY_USB_TYPE_DCP;
612 break;
613 case BQ25790_OTG_MODE:
614 val->intval = POWER_SUPPLY_USB_TYPE_PD_DRP;
615 break;
616
617 default:
618 val->intval = POWER_SUPPLY_USB_TYPE_UNKNOWN;
619 break;
620 }
621 break;
622
623 case POWER_SUPPLY_PROP_HEALTH:
> 624 if (state.fault_1 && (BQ25790_OTG_OVP | BQ25790_VSYS_OVP))
625 val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
626 else
627 val->intval = POWER_SUPPLY_HEALTH_GOOD;
628
629 switch (state.health) {
630 case BQ25790_TEMP_HOT:
631 val->intval = POWER_SUPPLY_HEALTH_HOT;
632 break;
633 case BQ25790_TEMP_WARM:
634 val->intval = POWER_SUPPLY_HEALTH_WARM;
635 break;
636 case BQ25790_TEMP_COOL:
637 val->intval = POWER_SUPPLY_HEALTH_COOL;
638 break;
639 case BQ25790_TEMP_COLD:
640 val->intval = POWER_SUPPLY_HEALTH_COLD;
641 break;
642 }
643 break;
644 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
645 ret = bq25790_get_ichg_curr(bq);
646 if (ret < 0)
647 return ret;
648
649 val->intval = ret;
650 break;
651
652 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
653 ret = bq25790_get_chrg_volt(bq);
654 if (ret < 0)
655 return ret;
656
657 val->intval = ret;
658 break;
659
660 case POWER_SUPPLY_PROP_PRECHARGE_CURRENT:
661 ret = bq25790_get_prechrg_curr(bq);
662 if (ret < 0)
663 return ret;
664
665 val->intval = ret;
666 break;
667 case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
668 ret = bq25790_get_term_curr(bq);
669 if (ret < 0)
670 return ret;
671
672 val->intval = ret;
673 break;
674 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
675 val->intval = state.vbus_adc;
676 break;
677 case POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT:
678 ret = bq25790_get_input_volt_lim(bq);
679 if (ret < 0)
680 return ret;
681
682 val->intval = ret;
683 break;
684 case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
685 ret = bq25790_get_input_curr_lim(bq);
686 if (ret < 0)
687 return ret;
688
689 val->intval = ret;
690 break;
691 default:
692 return -EINVAL;
693 }
694
695 return ret;
696 }
697
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH v3 2/2] power: supply: bq25790: Introduce the BQ25790 charger driver
In reply to Dan MurphyHi Dan,
url: https://github.com/0day-ci/linux/commits/Dan-Murphy/dt-bindings-power-Add-the-bq25790-dt-bindings/20201008-234450 base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next config: i386-randconfig-m021-20201009 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
smatch warnings:drivers/power/supply/bq25790_charger.c:170 bq25790_usb_work() warn: ignoring unreachable code. drivers/power/supply/bq25790_charger.c:624 bq25790_get_property() warn: should this be a bitwise op?
vim +170 drivers/power/supply/bq25790_charger.c
bc435a97ea513a3 Dan Murphy 2020-10-08 154 static void bq25790_usb_work(struct work_struct *data)
bc435a97ea513a3 Dan Murphy 2020-10-08 155 {
bc435a97ea513a3 Dan Murphy 2020-10-08 156 struct bq25790_device *bq =
bc435a97ea513a3 Dan Murphy 2020-10-08 157 container_of(data, struct bq25790_device, usb_work);
bc435a97ea513a3 Dan Murphy 2020-10-08 158
bc435a97ea513a3 Dan Murphy 2020-10-08 159 switch (bq->usb_event) {
bc435a97ea513a3 Dan Murphy 2020-10-08 160 case USB_EVENT_ID:
bc435a97ea513a3 Dan Murphy 2020-10-08 161 break;
bc435a97ea513a3 Dan Murphy 2020-10-08 162
bc435a97ea513a3 Dan Murphy 2020-10-08 163 case USB_EVENT_NONE:
bc435a97ea513a3 Dan Murphy 2020-10-08 164 power_supply_changed(bq->charger);
bc435a97ea513a3 Dan Murphy 2020-10-08 165 break;
bc435a97ea513a3 Dan Murphy 2020-10-08 166 }
bc435a97ea513a3 Dan Murphy 2020-10-08 167
bc435a97ea513a3 Dan Murphy 2020-10-08 168 return;
^^^^^^
bc435a97ea513a3 Dan Murphy 2020-10-08 169
bc435a97ea513a3 Dan Murphy 2020-10-08 @170 dev_err(bq->dev, "Error switching to charger mode.\n");
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Unreachable.
bc435a97ea513a3 Dan Murphy 2020-10-08 171 }
The bitwise warning is this:
if (state.fault_1 && (BQ25790_OTG_OVP | BQ25790_VSYS_OVP))
^^This && should be &.
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH v3 2/2] power: supply: bq25790: Introduce the BQ25790 charger driver
Dan
Quoted 7 lines · Dan Carpenter
Hi Dan,
url: https://github.com/0day-ci/linux/commits/Dan-Murphy/dt-bindings-power-Add-the-bq25790-dt-bindings/20201008-234450 base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next config: i386-randconfig-m021-20201009 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
Quoted 7 lines
If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>smatch warnings:
drivers/power/supply/bq25790_charger.c:170bq25790_usb_work()warn: ignoring unreachable code.drivers/power/supply/bq25790_charger.c:624bq25790_get_property()warn: should this be a bitwise op?
Fixing both of these now
Dan