Commit graph

48 commits

Author SHA1 Message Date
Hans de Goede c1ae3a4efb power: supply: bq25890: Use the devm_regmap_field_bulk_alloc() helper
Use the devm_regmap_field_bulk_alloc() helper function instead of
open-coding this ourselves.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:12 +01:00
Yauhen Kharuzhy 48f45b094d power: supply: bq25890: Support higher charging voltages through Pump Express+ protocol
Add a "linux,pump-express-vbus-max" property which indicates if the Pump
Express+ protocol should be used to increase the charging protocol.

If this new property is set and a DCP charger is detected then request
a higher charging voltage through the Pump Express+ protocol.

So far this new property is only used on x86/ACPI (non devicetree) devs,
IOW it is not used in actual devicetree files. The devicetree-bindings
maintainers have requested properties like these to not be added to the
devicetree-bindings, so the new property is deliberately not added
to the existing devicetree-bindings.

Changes by Hans de Goede:
- Port to my bq25890 patch-series + various cleanups
- Make behavior configurable through a new "linux,pump-express-vbus-max"
  device-property
- Sleep 1 second before re-checking the Vbus voltage after requesting
  it to be raised, to ensure that the ADC has time to sampled the new Vbus
- Add VBUSV bq25890_tables[] entry and use it in bq25890_get_vbus_voltage()
- Tweak commit message

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Co-developed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:12 +01:00
Hans de Goede eab25b4f93 power: supply: bq25890: On the bq25892 set the IINLIM based on external charger detection
The bq25892 does not have builtin charger-type detection like the bq25980,
there might be some external charger detection capability, which will be
modelled as a power_supply class-device supplying the bq25892.

Use the usb_type property value from the supplier psy-device to set the
input-current-limit (when available).

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:12 +01:00
Hans de Goede 79d35365a5 power: supply: bq25890: Add support for registering the Vbus boost converter as a regulator
The bq25890_charger code supports enabling/disabling the boost converter
based on usb-phy notifications. But the usb-phy framework is not used on
all boards/platforms. At support for registering the Vbus boost converter
as a standard regulator when there is no usb-phy on the board.

Also add support for providing regulator_init_data through platform_data
for use on boards where device-tree is not used and the platform code must
thus provide the regulator_init_data.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:12 +01:00
Hans de Goede 5575802d78 power: supply: bq25890: Add bq25890_set_otg_cfg() helper
Add a bq25890_set_otg_cfg() helper function, this is a preparation
patch for adding regulator support.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:11 +01:00
Hans de Goede f481d5b80b power: supply: bq25890: Drop dev->platform_data == NULL check
Drop the "if (!dev->platform_data)" check, this seems to be an attempt
for allowing loading the driver on devices without devicetree stemming
from the initial commit of the driver (with the presumed intention being
the "return -ENODEV" else branch getting replaced with something else).

With the new "linux,skip-init" and "linux,read-back-settings" properties
the driver can actually supports devices without devicetree and this
check no longer makes sense.

While at it, also switch to dev_err_probe(), which is already used in
various other places in the driver.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:11 +01:00
Hans de Goede 06c75095e8 power: supply: bq25890: Enable charging on boards where we skip reset
On boards where the "linux,skip-reset" boolean property is set we don't
reset the charger; and on some boards where the fw takes care of
initalizition F_CHG_CFG is set to 0 before handing control over to the OS.

Explicitly set F_CHG_CFG to 1 on boards where we don't reset the charger,
so that charging is always enabled on these boards, like it is always
enabled on boards where we do reset the charger.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:11 +01:00
Hans de Goede 40428bd467 power: supply: bq25890: Add support to read back the settings from the chip
On most x86/ACPI devices there is no devicetree to supply the necessary
init-data. Instead the firmware already fully initializes the bq25890
charger at boot. To support this, add support for reading back the
settings from the chip through a new "linux,read-back-settings" boolean.

So far this new property is only used on x86/ACPI (non devicetree) devs,
IOW it is not used in actual devicetree files. The devicetree-bindings
maintainers have requested properties like these to not be added to the
devicetree-bindings, so the new property is deliberately not added
to the existing devicetree-bindings.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:11 +01:00
Hans de Goede 7e3b8e357f power: supply: bq25890: Add support to skip reset at probe() / remove()
On most x86/ACPI devices the firmware already fully initializes
the bq25890 charger at boot, in this case it is best to not reset
it at probe() time.

At support for a new "linux,skip-reset" boolean property to support this.
So far this new property is only used on x86/ACPI (non devicetree) devs,
IOW it is not used in actual devicetree files. The devicetree-bindings
maintainers have requested properties like these to not be added to the
devicetree-bindings, so the new property is deliberately not added
to the existing devicetree-bindings.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:11 +01:00
Hans de Goede 7b22a97464 power: supply: bq25890: Add a bq25890_rw_init_data() helper
On most x86/ACPI devices there is no devicetree to supply the necessary
init-data. Instead the firmware already fully initializes the bq25890
charger at boot.

Factor out the current code to write all the init_data from devicetree
into a new bq25890_rw_init_data() helper which can both write the data
to the charger (the current behavior) as well as read it back from
the charger into the init_data struct.

This is a preparation patch for adding support for x86/ACPI device's
where the init_data must be read back from the bq25890 charger.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:11 +01:00
Yauhen Kharuzhy c562a43a46 power: supply: bq25890: Reduce reported CONSTANT_CHARGE_CURRENT_MAX for low temperatures
Take into account possible current reduction due to low-temperature when
reading POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX. As described in
the datasheet in cool (0-20° Celcius) conditions the current limit is
decreased to 20% or 50% of ICHG field value depended on JEITA_ISET field.

Also add NTC_FAULT field value to the debug message in
bq25890_get_chip_state().

Changed by Hans de Goede:
- Fix reading F_CHG_FAULT instead of F_NTC_FIELD for state->ntc_fault
- Only read JEITA_ISET field if necessary
- Tweak commit message a bit

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Co-developed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:11 +01:00
Yauhen Kharuzhy 766873c139 power: supply: bq25890: Rename IILIM field to IINLIM
Rename the Input Current Limit field in the REG00 from IILIM to IINLIM
accordingly with the bq2589x datasheet. This is just cosmetical change
to reduce confusion.

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:11 +01:00
Linus Torvalds 039053c119 power supply and reset changes for the v5.17 series
power-supply core:
  - introduce "No Battery" health status
  - use library interpolation
  - add power_supply_battery_info documentation
  - migrate power_supply_battery_info to be fully heap allocated
    making it more obvious that it needs to be free'd manually
 
 Drivers:
  - max77976-charger: new driver
  - qcom-smbb: add pm8226 charger support
  - bq25890-charger: support battery temperature readings
  - ab8500: continue migrating towards using standard core APIs
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmHb+9YACgkQ2O7X88g7
 +pqhGw/+NyqnkSIsU4udxYJY47ooaZ7f2rApFueJSre0Xzwi37SQFFvstBb196YP
 B1mr2H16Slni0kRItu+B1H04mI1y1o7zT4E84s1DoMQjILLtxh+LiT8tefhhWtBs
 5a6IiUKtxo2HZZgreTqyAAjqPYkdRGDkChK87zBZdxIGcaGHXkRlyuTSR2P406r/
 qvA5uCkVg7CMqXf0RemcIlEOvSxaPXZz+PVJjn6qbjSioQHtOekoxoMBziy31Nhm
 Qp0sEYYlW6ZRpaP/IFU21sZb8zaH+isOrg2U/LttgfABdwtEVUz/nygZwSD0ncBi
 zSUrc4Mu/goh7m5oY91HUsis3fzgABMd/xdaDDzJoh91LvguE9lA2vP5r7hEDLVD
 S7v9RNNEfALce5sHGAEXQX0IztD0xZhSRe6jpeAYLVB0OG1Tae3q/6dlEHQsz2rb
 oANYsxrAU0hf2MnsXa6FnR1cnVJNm7z/bQpTFbU7guSX8Vi5n8jzmghoi3piCjyk
 9YXMROuivXuaBz1wXNk2IXzdYwtOTeateo2yYdSQol3UnYgUtIrn+qBVeuElbC3C
 qkb21yTpEIk3aoZOjbKFze7ks6L8c5Nip+66s4WkcAucK3Uxii1QpTR9f1+TdxN0
 vjybsIRHqPnCh6yl1JR/0NNvFPGQWkJt6sveQXas/LAZ77MOMro=
 =9cda
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:
 "Power-supply core:

   - introduce "No Battery" health status

   - use library interpolation

   - add power_supply_battery_info documentation

   - migrate power_supply_battery_info to be fully heap allocated making
     it more obvious that it needs to be free'd manually

  Drivers:

   - max77976-charger: new driver

   - qcom-smbb: add pm8226 charger support

   - bq25890-charger: support battery temperature readings

   - ab8500: continue migrating towards using standard core APIs"

* tag 'for-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (28 commits)
  power: supply_core: Pass pointer to battery info
  power: supply: ab8500: Fix the error handling path of ab8500_charger_probe()
  power: reset: mt6397: Check for null res pointer
  power: bq25890: add POWER_SUPPLY_PROP_TEMP
  power: supply: qcom_smbb: support pm8226
  dt-bindings: power: supply: pm8941-charger: add pm8226
  power: supply: ab8500: Standardize capacity lookup
  power: supply: ab8500: Standardize temp res lookup
  power: supply: ab8500: Standardize CV voltage
  power: supply: ab8500: Standardize CC current
  power: supply: ab8500: Make recharge capacity a constant
  power: supply: ab8500: Standardize termination current
  power: supply: ab8500: Standardize internal resistance
  power: supply: ab8500_fg: Init battery data in bind()
  power: supply: ab8500: Standardize voltages
  power: supply: ab8500: Standardize technology
  power: supply: ab8500: Standardize design capacity
  power: supply: ab8500: Use only one battery type
  power: supply: ab8500: Drop unused battery types
  power: supply: ab8500: Standardize operating temperature
  ...
2022-01-11 11:20:27 -08:00
Angus Ainslie 9652c02428 power: bq25890: add POWER_SUPPLY_PROP_TEMP
Add the POWER_SUPPLY_PROP_TEMP and a NTC 10K percent VREGN to degrees LUT.

Make sure that a conversion is forced when the power supply is offline so
the temperature is valid.

Signed-off-by: Angus Ainslie <angus@akkea.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-12-02 18:27:06 +01:00
Yauhen Kharuzhy 80211be1b9 power: bq25890: Enable continuous conversion for ADC at charging
Instead of one shot run of ADC at beginning of charging, run continuous
conversion to ensure that all charging-related values are monitored
properly (input voltage, input current, themperature etc.).

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-11-15 15:09:54 +01:00
Hans de Goede 22ad4f99f6 power: supply: bq25890: Fix initial setting of the F_CONV_RATE field
The code doing the initial setting of the F_CONV_RATE field based
on the bq->state.online flag. In order for this to work properly,
this must be done after the initial bq25890_get_chip_state() call.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-11-02 16:48:47 +01:00
Hans de Goede d01363da53 power: supply: bq25890: Fix race causing oops at boot
Before this commit the driver was registering its interrupt handler before
it registered the power_supply, causing bq->charger to potentially be NULL
when the interrupt handler runs, triggering a NULL pointer exception in
the interrupt handler:

[   21.213531] BUG: kernel NULL pointer dereference, address: 0000000000000680
...
[   21.213573] Hardware name: Xiaomi Inc Mipad2/Mipad, BIOS MIPad-P4.X64.0043.R03.1603071414 03/07/2016
[   21.213576] RIP: 0010:__lock_acquire+0x5c5/0x1de0
...
[   21.213629] Call Trace:
[   21.213636]  ? disable_irq_nosync+0x10/0x10
[   21.213644]  ? __mutex_unlock_slowpath+0x35/0x260
[   21.213655]  lock_acquire+0xb5/0x2b0
[   21.213661]  ? power_supply_changed+0x23/0x90
[   21.213670]  ? disable_irq_nosync+0x10/0x10
[   21.213676]  _raw_spin_lock_irqsave+0x48/0x60
[   21.213682]  ? power_supply_changed+0x23/0x90
[   21.213687]  power_supply_changed+0x23/0x90
[   21.213697]  __bq25890_handle_irq+0x5e/0xe0 [bq25890_charger]
[   21.213709]  bq25890_irq_handler_thread+0x26/0x40 [bq25890_charger]
[   21.213718]  irq_thread_fn+0x20/0x60
...

Fix this by moving the power_supply_register() call to above the
request_threaded_irq() call.

Note this fix includes making the following 2 (necessary) changes:

1. Switch to the devm version of power_supply_register() to avoid the
need to make the error-handling in probe() more complicated.

2. Rename the "irq_fail" label to "err_unregister_usb_notifier" since
the old name no longer makes sense after this fix.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-11-02 16:48:47 +01:00
Martin Kepplinger 172d0ccea5 power: bq25890: add return values to error messages
Add more details to the error messages that indicate what went wrong
and use dev_err_probe() at a few places in the probe() path in order
to avoid error messages for deferred probe after which the driver probes
correctly.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-10-18 18:27:40 +02:00
Sebastian Krzyszkowiak d4e9e7b6f7 power: supply: bq25890: Use the correct range for IILIM register
I've checked bq25890, bq25892, bq25895 and bq25896 datasheets and
they all define IILIM to be between 100mA-3.25A with 50mA steps.

Fixes: 478efc79ee ("power: bq25890: implement INPUT_CURRENT_LIMIT property")
Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
Reviewed-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-11-29 23:06:03 +01:00
Krzysztof Kozlowski 02067dc96c power: supply: bq25890: skip 'struct acpi_device_id' when !CONFIG_ACPI
Since ACPI_PTR() is used to NULLify the value when !CONFIG_ACPI, the
struct acpi_device_id becomes unused:

  drivers/power/supply/bq25890_charger.c:1076:36: warning:
    'bq25890_acpi_match' defined but not used [-Wunused-const-variable=]

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-10-03 22:17:50 +02:00
Michał Mirosław 724083293e power: supply: bq25890: support IBAT compensation
Add configuration for compensation of IBAT measuring resistor in series
with the battery.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-09-30 01:12:22 +02:00
Michał Mirosław 478efc79ee power: bq25890: implement INPUT_CURRENT_LIMIT property
Report REG00.IINLIM value as INPUT_CURRENT_LIMIT property.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-10 23:44:20 +02:00
Michał Mirosław c942656ddb power: bq25890: implement PRECHARGE_CURRENT property
Report configured precharge current.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-10 23:43:50 +02:00
Michał Mirosław b302a0ae72 power: bq25890: implement CHARGE_TYPE property
Report charging type based on recently read state.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-10 23:42:51 +02:00
Michał Mirosław 3b4df57bef power: bq25890: update state on property read
Edge interrupts from the charger may be lost or stuck in fault mode
since probe(). Check if something changed everytime userspace wants
some data.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-10 23:41:53 +02:00
Michał Mirosław 21d90eda43 power: bq25890: fix ADC mode configuration
Datasheet describes two modes for reading ADC measurements:
1. continuous, 1 Hz - enabled and started by CONV_RATE bit
2. one-shot - triggered by CONV_START bit

In continuous mode, CONV_START is read-only and signifies an ongoing
conversion.

Change the code to follow the datasheet and really disable continuous
mode for power saving.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-10 23:06:33 +02:00
Michał Mirosław 1e4724d0b7 power: bq25890: use proper CURRENT_NOW property for I_BAT
Charge Current is more apropriately reflected by CURRENT_NOW property
(measured current) than CONSTANT_CURRENT_VOLTAGE (configured CC-phase
current limit). Fix the reference and make the sign reflect direction
of the current.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-10 22:55:22 +02:00
Dan Carpenter cf5701bf74 power: bq25890: unlock on error paths in bq25890_resume()
We introduced some new locking here, but need to update the error
paths so they unlock before returning.

Fixes: 72d9cd9cdc ("power: bq25890: protect view of the chip's state")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-09 01:59:37 +02:00
Michał Mirosław 72d9cd9cdc power: bq25890: protect view of the chip's state
Extend bq->lock over whole updating of the chip's state. Might get
useful later for switching ADC modes correctly.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-03 22:33:35 +02:00
Michał Mirosław a9c2419406 power: bq25890: remove redundant I2C bus check
regmap initialization will check I2C adapter functionality.
Remove redundant check in the driver.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-03 21:51:03 +02:00
Michał Mirosław a6a48fac96 power: bq25890: make property table const
Property list should not change, so mark it const.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-03 21:50:21 +02:00
Michał Mirosław 5956fca78f power: bq25890: simplify chip name property getter
Driver rejects unknown chips early in the probe(), so when
bq25890_power_supply_get_property() is made reachable, bq->chip_version
will already be set to correct value - there is no need to check
it again.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-05-03 21:49:34 +02:00
Colin Ian King cb619e8033 power: supply: bq25890_charger: fix incorrect error return when bq25890_field_read fails
Currently a read failure by bq25890_field_read on F_DEV_REV is returning
an error in id instead of rev. Fix this by returning the value in rev.

Addresses-Coverity: ("Copy-paste error")
Fixes: d20267c9a9 ("power: supply: bq25890_charger: Add support of BQ25892 and BQ25896 chips")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-01-16 20:35:57 +01:00
Yauhen Kharuzhy 46aa27e742 power: supply: bq25890_charger: Add DT and I2C ids for all supported chips
Add bq25892, bq25895 and bq25896 to list of supported device IDs for
DeviceTree and I2C.

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-01-14 23:37:20 +01:00
Yauhen Kharuzhy d20267c9a9 power: supply: bq25890_charger: Add support of BQ25892 and BQ25896 chips
Support BQ25892 and BQ25896 chips by this driver. They shared one chip
ID 0, so distinquish them by device revisions (2 for 25896 and 1 for
25892).

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-01-14 23:27:28 +01:00
Angus Ainslie (Purism) 5c35ba9b47 power: supply: bq25890_charger: Add the BQ25895 part
The BQ25895 is almost identical to the BQ25890.

Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 21:12:08 +02:00
Linus Torvalds 5fe7b600a1 power supply and reset changes for the v5.3 series
Core:
  * Add HWMON compat layer
  * New properties
   - input power limit
   - input voltage limit
 
 Drivers:
  * qcom-pon: add gen2 support
  * New driver for storing reboot move in NVMEM
  * New driver for Wilco EC charger configuration
  * simplify getting the adapter of a client
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAl0s0xgACgkQ2O7X88g7
 +pqxFQ/9GmfgHpzZ+qQmpBR5zyw1+yrhls3BXYEgHtGM+3YZ6n1sF8Yl1eUYpviC
 ldvN3vHXaxRlG5eDBwMl3ScWZnaxMpZssigO3lL4o+kYng0c0xqaPZZYxA9oJNgn
 0ertZrYcQZWmT82aRnjt2/p+8n+Hld6bv89PodWdLvsDvId1qQPXu5ILV0JL/QNK
 FMQepuaiRu9VXlyPCuWYwoOmKruZjLF7SOyis+I4e55U7lHeyCOySH/tZTTFgd+n
 hUpWm4ekc7YCAJVVJUQcdBtfNvQm1KtGkLSnSockH/636kP2fh5ESj76z8i5I6/6
 yl7OrkCyhespqS9hGCKCPU95s8MQe8HurlGR8aIWHLJJMiv1hIVOq7n9Uj+mmdRS
 OkKQHo/RUxXn5ioCUF3F3NcB94/95f0AWrx3RXjeXd2kYlUmVKCHyaGjPT9WfSOe
 MUcLZwM+GsG+3SWBhPGqjuIhIGfBBuQk+mcYLPLP/j3emNeLByYEtEDhvoQbEooU
 TCyJGR+FGIAyjXcW/uZzxx8MiZPybSXo7a4j837Cx6sRNwZJ4V9Ve/7XdUy7DKD0
 kOBH/ndJhoKJQkup+HEGmv/8os4K8gyW/kaiu718mS0oLDfQGDy0C0Y8BNoJnw4k
 /jo/1q0KY+8Hd6bxqbommA2ORAw7XsDZB7eWWC4gDqMXVcF1S6k=
 =fmGg
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:
 "Core:
   - add HWMON compat layer
   - new properties:
       - input power limit
       - input voltage limit

  Drivers:
   - qcom-pon: add gen2 support
   - new driver for storing reboot move in NVMEM
   - new driver for Wilco EC charger configuration
   - simplify getting the adapter of a client"

* tag 'for-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  power: reset: nvmem-reboot-mode: add CONFIG_OF dependency
  power_supply: wilco_ec: Add charging config driver
  power: supply: cros: allow to set input voltage and current limit
  power: supply: add input power and voltage limit properties
  power: supply: fix semicolon.cocci warnings
  power: reset: nvmem-reboot-mode: use NVMEM as reboot mode write interface
  dt-bindings: power: reset: add document for NVMEM based reboot-mode
  reset: qcom-pon: Add support for gen2 pon
  dt-bindings: power: reset: qcom: Add qcom,pm8998-pon compatibility line
  power: supply: Add HWMON compatibility layer
  power: supply: sbs-manager: simplify getting the adapter of a client
  power: supply: rt9455_charger: simplify getting the adapter of a client
  power: supply: rt5033_battery: simplify getting the adapter of a client
  power: supply: max17042_battery: simplify getting the adapter of a client
  power: supply: max17040_battery: simplify getting the adapter of a client
  power: supply: max14656_charger_detector: simplify getting the adapter of a client
  power: supply: bq25890_charger: simplify getting the adapter of a client
  power: supply: bq24257_charger: simplify getting the adapter of a client
  power: supply: bq24190_charger: simplify getting the adapter of a client
2019-07-15 21:06:15 -07:00
Wolfram Sang 124db1f91b power: supply: bq25890_charger: simplify getting the adapter of a client
We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-06-23 18:02:34 +02:00
Thomas Gleixner c942fddf87 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157
Based on 3 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version this program is distributed in the
  hope that it will be useful but without any warranty without even
  the implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version [author] [kishon] [vijay] [abraham]
  [i] [kishon]@[ti] [com] this program is distributed in the hope that
  it will be useful but without any warranty without even the implied
  warranty of merchantability or fitness for a particular purpose see
  the gnu general public license for more details

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version [author] [graeme] [gregory]
  [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
  [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
  [hk] [hemahk]@[ti] [com] this program is distributed in the hope
  that it will be useful but without any warranty without even the
  implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 1105 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:37 -07:00
Michał Mirosław f83a6ece69 power: supply: bq25890: show max charge current/voltage as configured
Use firmware-provided limits for POWER_SUPPLY_*_MAX properties instead
of chip max values. This will reflect the battery limits as those are
the important ones.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-23 22:29:45 +01:00
Michał Mirosław 9580913966 power: supply: bq25890: fix BAT_COMP field definition
According to datasheet, BAT_COMP field spans bits 5-7. The rest of the
code seems to assume this already.

Fixes: 4aeae9cb0d ("power_supply: Add support for TI BQ25890 charger chip")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-18 00:21:16 +01:00
kbuild test robot ad1570d99f power: supply: bq25890_charger: fix semicolon.cocci warnings
drivers/power/supply/bq25890_charger.c:614:2-3: Unneeded semicolon
drivers/power/supply/bq25890_charger.c:621:2-3: Unneeded semicolon
drivers/power/supply/bq25890_charger.c:630:3-4: Unneeded semicolon
drivers/power/supply/bq25890_charger.c:638:2-3: Unneeded semicolon
drivers/power/supply/bq25890_charger.c:644:2-3: Unneeded semicolon

 Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

Fixes: 9d9ae3414d ("power: supply: bq25890_charger: Add debugging output of failed initialization")
CC: Angus Ainslie (Purism) <angus@akkea.ca>
Signed-off-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-18 12:35:51 +02:00
Angus Ainslie (Purism) ae6fe7a387 power: supply: bq25890_charger: Read back the current battery voltage
The BQ2589x family has the capability of reading the current battery voltage.

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 11:29:10 +02:00
Angus Ainslie (Purism) 2e1a2ddee9 power: supply: bq25890_charger: Add the BQ25896 part
The BQ25896 is almost identical to the BQ25890.

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 11:29:04 +02:00
Angus Ainslie (Purism) 0838d84fff power: supply: bq25890_charger: Remove unused table entries
There are a few table entries that aren't used. Drop them.

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 11:28:57 +02:00
Angus Ainslie (Purism) 9d9ae3414d power: supply: bq25890_charger: Add debugging output of failed initialization
To ease adding a new part variant some debugging is handy.

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Angus Ainslie (Purism) <angus@akkea.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 11:28:48 +02:00
Andy Shevchenko 867758793a power: supply: bq25890: Use gpiod_get()
Since index is always 0, replace gpiod_get_index() by gpiod_get().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-04-14 01:41:34 +02:00
Sebastian Reichel 8c0984e5a7 power: move power supply drivers to power/supply
This moves all power supply drivers from drivers/power/
to drivers/power/supply/. The intention is a cleaner
source tree, since drivers/power/ also contains frameworks
unrelated to power supply, like adaptive voltage scaling.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-08-11 01:11:03 +02:00
Renamed from drivers/power/bq25890_charger.c (Browse further)