Commit graph

2400 commits

Author SHA1 Message Date
Niklas Cassel
cad12cdeea power: avs: qcom-cpr: fix unsigned expression compared with zero
drivers/power/avs/qcom-cpr.c:1539:5-21:
warning: unsigned expression compared with zero: drv->num_corners < 0

Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Niklas Cassel <nks@flawful.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-12-29 22:11:22 +01:00
Niklas Cassel
e808926b4d power: avs: qcom-cpr: fix invalid printk specifier in debug print
drivers/power/avs/qcom-cpr.c:838:15:
warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘ssize_t’

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Niklas Cassel <nks@flawful.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-12-29 22:11:22 +01:00
Niklas Cassel
bf6910abf5 power: avs: Add support for CPR (Core Power Reduction)
CPR (Core Power Reduction) is a technology that reduces core power on a
CPU or other device. It reads voltage settings in efuse from product
test process as initial settings.
Each OPP corresponds to a "corner" that has a range of valid voltages
for a particular frequency. While the device is running at a particular
frequency, CPR monitors dynamic factors such as temperature, etc. and
adjusts the voltage for that frequency accordingly to save power
and meet silicon characteristic requirements.

This driver is based on an RFC by Stephen Boyd[1], which in turn is
based on work by others on codeaurora.org[2].

[1] https://lkml.org/lkml/2015/9/18/833
[2] https://source.codeaurora.org/quic/la/kernel/msm-4.14/tree/drivers/regulator/cpr-regulator.c?h=msm-4.14

Co-developed-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-12-20 10:25:24 +01:00
Ma Feng
921377c0b4 power: supply: abx500_chargalg: Remove unneeded semicolon
Fixes coccicheck warning:

drivers/power/supply/abx500_chargalg.c:1826:2-3: Unneeded semicolon

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Ma Feng <mafeng.ma@huawei.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 18:05:28 +01:00
Ma Feng
e15c54d208 power: supply: ab8500_charger: Remove unneeded semicolon
Fixes coccicheck warning:

drivers/power/supply/ab8500_charger.c:1082:2-3: Unneeded semicolon
drivers/power/supply/ab8500_charger.c:792:2-3: Unneeded semicolon
drivers/power/supply/ab8500_charger.c:2430:2-3: Unneeded semicolon

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Ma Feng <mafeng.ma@huawei.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 18:05:28 +01:00
Ma Feng
c6ef5234ef power: supply: ab8500: Remove unneeded semicolon
Fixes coccicheck warning:

drivers/power/supply/ab8500_fg.c:2224:5-6: Unneeded semicolon
drivers/power/supply/ab8500_fg.c:2227:4-5: Unneeded semicolon
drivers/power/supply/ab8500_fg.c:2334:3-4: Unneeded semicolon
drivers/power/supply/ab8500_fg.c:2342:3-4: Unneeded semicolon
drivers/power/supply/ab8500_fg.c:2350:3-4: Unneeded semicolon
drivers/power/supply/ab8500_fg.c:2358:3-4: Unneeded semicolon
drivers/power/supply/ab8500_fg.c:2366:3-4: Unneeded semicolon

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Ma Feng <mafeng.ma@huawei.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 18:05:28 +01:00
Jean-Francois Dagenais
e2ec6aef37 power: supply: sbs-battery: fix CAPACITY_MODE bit naming
"Battery mode" is the name of the register, the bit manipulated by this
code is "CAPACITY_MODE" (Smart Battery System Specifications).

Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 02:11:18 +01:00
Jean-Francois Dagenais
75d8a8423c power: supply: sbs-battery: use octal permissions on module param
Symbolic permissions 'S_IRUSR | S_IRGRP | S_IROTH' are not
preferred. Use octal permissions '0444'.

Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 02:05:51 +01:00
Krzysztof Kozlowski
463881ac40 power: reset: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in
coding style with command like:
	$ sed -e 's/^        /\t/' -i */Kconfig

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 02:03:50 +01:00
Enric Balletbo i Serra
464aca1648 power: supply: cros_usbpd: Remove dev_err() getting the number of ports
When a device has no support to get the charger number of ports, it
doesn't have to result in a dev_err(), print saying "Could not get
charger port count" using a dev_info() would suffice. In such case,
the dev_info() message is already printed but the dev_err() is annoying,
specially, on those devices that doesn't support the command. So remove
the dev_err().

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:58:44 +01:00
Matheus Castello
a08990ea11 power: supply: max17040: Send uevent in SOC and status change
Notify core through power_supply_changed() in case of changes in state
of charge and power supply status. This is useful for user-space to
efficiently update current battery level.

Signed-off-by: Matheus Castello <matheus@castello.eng.br>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:51:52 +01:00
Matheus Castello
cccdd0ca1c power: supply: max17040: Config alert SOC low level threshold from FDT
For configuration of fuel gauge alert for a low level state of charge
interrupt we add a function to config level threshold and a device tree
binding property to set it in flatned device tree node.

Now we can use "maxim,alert-low-soc-level" property with the values from
1% up to 32% to configure alert interrupt threshold.

Signed-off-by: Matheus Castello <matheus@castello.eng.br>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:51:52 +01:00
Matheus Castello
2e17ed94de power: supply: max17040: Add IRQ handler for low SOC alert
According datasheet max17040 has a pin for alert host for low SOC.
This pin can be used as external interrupt, so we need to check for
interrupts assigned for device and handle it.

In handler we are checking and storing fuel gauge registers values
and send an uevent to notificate user space, so user space can decide
save work or turn off since the alert demonstrate that the battery may
no have the power to keep the system turned on for much longer.

Signed-off-by: Matheus Castello <matheus@castello.eng.br>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:51:52 +01:00
Baolin Wang
058d42563a power: supply: sc27xx: Calibrate the resistance of coulomb counter
There are some deviations between the real resistance and the ideal
resistance of coulomb counter, which will affect the accuracy of
the coulomb counter, thus calibrate the real resistance of coulomb
counter to improve the accuracy.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:37:54 +01:00
Yuanjiang Yu
6af8288834 power: supply: sc27xx: Optimize the battery resistance with measuring temperature
Optimize the battery internal resistance in a certain temerature to
get a accurate battery internal resistance.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:36:33 +01:00
Baolin Wang
65dbad713d power: supply: core: Add battery internal resistance temperature table support
Since the battery internal resistance can be changed with the temperature
changes, thus add a resistance temperature table support to look up
the accurate battery internal resistance in a certain temperature.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:36:32 +01:00
Bartosz Golaszewski
5de1780181 power: supply: max77650: add of_match table
We need the of_match table if we want to use the compatible string in
the pmic's child node and get the charger driver loaded automatically.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:13:26 +01:00
Angus Ainslie (Purism)
bc90705bbb power: supply: max17042: add MAX17055 support
The MAX17055 is very similar to the MAX17042 so extend the driver.

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-12-19 01:07:53 +01:00
Lucas Stach
a3d70dacc7 power: suppy: ucs1002: disable power when max current is 0
For some devices userspace needs the ability to completely cut the power
to the USB devices connected to the charge controller. An easy way to
achieve this is by allowing 0 as a valid max current and forcibly disable
the output in that case, as well as enable it again if the regulator is
in use and a non-0 max current is set.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Chris Healy <cphealy@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:07:53 +01:00
Krzysztof Kozlowski
3c9c2d0812 power: supply: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in
coding style with command like:
	$ sed -e 's/^        /\t/' -i */Kconfig

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:07:53 +01:00
Paul Cercueil
86b9182df8 power/supply: ingenic-battery: Don't change scale if there's only one
The ADC in the JZ4740 can work either in high-precision mode with a 2.5V
range, or in low-precision mode with a 7.5V range. The code in place in
this driver will select the proper scale according to the maximum
voltage of the battery.

The JZ4770 however only has one mode, with a 6.6V range. If only one
scale is available, there's no need to change it (and nothing to change
it to), and trying to do so will fail with -EINVAL.

Fixes: fb24ccfbe1 ("power: supply: add Ingenic JZ47xx battery driver.")

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Acked-by: Artur Rojek <contact@artur-rojek.eu>
Cc: stable@vger.kernel.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:07:53 +01:00
Chuhong Yuan
dd04defd11 power: supply: pda_power: add missed usb_unregister_notifier
The driver forgets to unregister the notifier in remove.
Add the call to fix it.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:07:53 +01:00
Chris Packham
b0d0d3de24 power: reset: gpio-restart: don't error on deferral
Don't generate an error message when devm_gpiod_get fails with
-EPROBE_DEFER.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-18 16:10:08 +01:00
Claudiu Beznea
1b6e21f283 drivers: soc: atmel: select POWER_RESET_AT91_SAMA5D2_SHDWC for sam9x60
Select POWER_RESET_AT91_SAMA5D2_SHDWC for SAM9X60 SoC.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/1575035505-6310-7-git-send-email-claudiu.beznea@microchip.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-10 00:45:30 +01:00
Claudiu Beznea
a79fa0c12c power: reset: Kconfig: select POWER_RESET_AT91_RESET for sam9x60
Select POWER_RESET_AT91_RESET for SAM9X60 SoC.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/1575035505-6310-6-git-send-email-claudiu.beznea@microchip.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-10 00:45:06 +01:00
Linus Torvalds
ef867c12f3 Additional power management updates for 5.5-rc1
- Avoid a race condition in the ACPI EC driver that may cause
    systems to be unable to leave suspend-to-idle (Rafael Wysocki).
 
  - Drop the "disabled" field, which is redundant, from struct
    cpuidle_state (Rafael Wysocki).
 
  - Reintroduce device PM QoS frequency constraints (temporarily
    introduced and than dropped during the 5.4 cycle) in preparation
    for adding QoS support to devfreq (Leonard Crestez).
 
  - Clean up indentation (in multiple places) and the cpuidle drivers
    help text in Kconfig (Krzysztof Kozlowski, Randy Dunlap).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAl3nhpQSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxQj4P/2HbVROWMON7q9iWhgO59qABEbqU8M7L
 DaJ2gu+bDe3FQ9Ek6Y2EObfGw3nl9riyGbZH/jVmcOkbuXE+aQXv/j7eEnM9G35+
 8+JSfhucVsohaHVxT2ROMv+7YD+pLyWK1ivuVK/dNcvmxQaC9CKrmn3GF2ujkqNR
 ahdRRzZobGeC6mc8tms3GYpWkd1R5zd74ALGVsw9i/eB3P/YgrlS8HaQynpbaflZ
 qhRKZgsTf8QD6+OG+6HQhWpOfAlG36dsJnvuk0Oa0Cpnw+Zfj6WoR1jpL9ufNWBM
 Re1faTfppy6Hnyxr62Ytkbq2pYozTVAnQM+TKNIGoqxA4OIXvhgQpBqApmuJXpRx
 ZFBfr943f7I2jmAAznHeiW9l3n+4h725rpoxKapnlO3OMRDwCTqxbMahiS+CDULd
 gSu4prnoBdd9WrwiR7M1PA4X2Eb2M0kYFQUr7BltlTgjLHjQy47Mnazh9WxYBAv8
 p1tip39QHeZcdO3rdW1O21ljNekEIOFAi5bVVECsR6RyA+KR+vHgFP9pMUWyCpgU
 +rde+MdGKIL3sw/szNhTTDfQ49vz/ObcipJg3/rakq6jXeFL4n5NwMy5jYrquPlx
 xxHx3Yp1PCBEZ1TXS6+JjznvQBU/G/7YvoWobpqwN/IL1wa55rWOX8Ah1+YnfLzF
 fGzh0EvPJKyM
 =KAyd
 -----END PGP SIGNATURE-----

Merge tag 'pm-5.5-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull additional power management updates from Rafael Wysocki:
 "These fix an ACPI EC driver bug exposed by the recent rework of the
  suspend-to-idle code flow, reintroduce frequency constraints into
  device PM QoS (in preparation for adding QoS support to devfreq), drop
  a redundant field from struct cpuidle_state and clean up Kconfig in
  some places.

  Specifics:

   - Avoid a race condition in the ACPI EC driver that may cause systems
     to be unable to leave suspend-to-idle (Rafael Wysocki)

   - Drop the "disabled" field, which is redundant, from struct
     cpuidle_state (Rafael Wysocki)

   - Reintroduce device PM QoS frequency constraints (temporarily
     introduced and than dropped during the 5.4 cycle) in preparation
     for adding QoS support to devfreq (Leonard Crestez)

   - Clean up indentation (in multiple places) and the cpuidle drivers
     help text in Kconfig (Krzysztof Kozlowski, Randy Dunlap)"

* tag 'pm-5.5-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  ACPI: PM: s2idle: Rework ACPI events synchronization
  ACPI: EC: Rework flushing of pending work
  PM / devfreq: Add missing locking while setting suspend_freq
  PM / QoS: Restore DEV_PM_QOS_MIN/MAX_FREQUENCY
  PM / QoS: Reorder pm_qos/freq_qos/dev_pm_qos structs
  PM / QoS: Initial kunit test
  PM / QoS: Redefine FREQ_QOS_MAX_DEFAULT_VALUE to S32_MAX
  power: avs: Fix Kconfig indentation
  cpufreq: Fix Kconfig indentation
  cpuidle: minor Kconfig help text fixes
  cpuidle: Drop disabled field from struct cpuidle_state
  cpuidle: Fix Kconfig indentation
2019-12-04 10:48:09 -08:00
Linus Torvalds
37323918ca - Core Frameworks
- Add support for a "resource managed strongly uncachable ioremap" call
    - Provide a collection of MFD helper macros
    - Remove mfd_clone_cell() from MFD core
    - Add NULL de-reference protection in MFD core
    - Remove superfluous function fd_platform_add_cell() from MFD core
    - Honour Device Tree's request to disable a device
 
  - New Drivers
    - Add support for MediaTek MT6323 PMIC
 
  - New Device Support
    - Add support for Gemini Lake to Intel LPSS PCI
    - Add support for Cherry Trail Crystal Cover PMIC to Intel SoC PMIC CRC
    - Add support for PM{I}8950 to Qualcomm SPMI PMIC
    - Add support for U8420 to ST-Ericsson DB8500
    - Add support for Comet Lake PCH-H to Intel LPSS PCI
 
  - New Functionality
    - Add support for requested supply clocks; madera-core
 
  - Fix-ups
    - Lower interrupt priority; rk808
    - Use provided helpers (macros, group functions, defines); rk808,
 		ipaq-micro, ab8500-core, db8500-prcmu, mt6397-core, cs5535-mfd
    - Only allocate IRQs on request; max77620
    - Use simplified API; arizona-core
    - Remove redundant and/or duplicated code; wm8998-tables, arizona, syscon
    - Device Tree binding fix-ups; madera, max77650, max77693
    - Remove mfd_cell->id abuse hack; cs5535-mfd
    - Remove only user of mfd_clone_cell(); cs5535-mfd
    - Make resources static; rohm-bd70528
 
  - Bug Fixes
    - Fix product ID for RK818; rk808
    - Fix Power Key; rk808
    - Fix booting on the BananaPi; mt6397-core
    - Endian fix-ups; twl.h
    - Fix static error checker warnings; ti_am335x_tscadc
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAl3f2k4ACgkQUa+KL4f8
 d2GmohAAluAT7hhURCf2HECsbVpeLH5i5UahRTCAlyIqeAiOjGEBGdIT2fYM1B+3
 daqj3XiiLqvlnT5FZc4Fw5gR9Nu6Oe+Fo+6p6NnAu7CIt+x9RXOTB5LLXYYKICZK
 c32SnsSbRQwtzu83d3CjlfQRUZh66fJksWVPnOBkenaR7HaQlujKydBAk3kkLygZ
 3GGTzjTXakl/53XJLRNn2wVVEG2gCicZwWxmWYW2000PFWo1upCeJRcwHBOXyy1I
 oh+KNp28gVQLT3pOte4TZEO3GNacMMs5DvA0hj2j7j+nH5FOryEPjUNbrqkcR+9T
 aquGbgYWgfJrW9UJhgNVsn754y5sgZ48Q20533AICMDfy3JTzfn91pX5q8mVFaPl
 Kf4cTVAau7kUCVxrXWuOG2fG2r7BjRABKU5ODDsGWmfWQNdktvLvHJI4j97ct0xj
 neBijJya70woV1o40v5yTmcUcc7hGEoKXuRWslxNK3K+nQkgRKMKgY4dm3jBeSmD
 lmBrjtjT0gcNl6+bOOn6IXn5k3sxWUwa799LUDaR5oHj6kB0LkIqz3h6UlOBryKO
 iQ2xXXCf/gAlkL75SW1rjYBHWkMkswgigppcbw2HB9tMqGL2LtHtgIli8CfGz1vs
 BzwxOQRvMK+4rG0qNHbocXJK2O4PduTxMXtBDiVK/tXrHaNLs7I=
 =mugH
 -----END PGP SIGNATURE-----

Merge tag 'mfd-next-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
 "Core Frameworks:
   - Add support for a "resource managed strongly uncachable ioremap"
     call
   - Provide a collection of MFD helper macros
   - Remove mfd_clone_cell() from MFD core
   - Add NULL de-reference protection in MFD core
   - Remove superfluous function fd_platform_add_cell() from MFD core
   - Honour Device Tree's request to disable a device

  New Drivers:
   - Add support for MediaTek MT6323 PMIC

  New Device Support:
   - Add support for Gemini Lake to Intel LPSS PCI
   - Add support for Cherry Trail Crystal Cover PMIC to Intel SoC PMIC
     CRC
   - Add support for PM{I}8950 to Qualcomm SPMI PMIC
   - Add support for U8420 to ST-Ericsson DB8500
   - Add support for Comet Lake PCH-H to Intel LPSS PCI

  New Functionality:
   - Add support for requested supply clocks; madera-core

  Fix-ups:
   - Lower interrupt priority; rk808
   - Use provided helpers (macros, group functions, defines); rk808,
     ipaq-micro, ab8500-core, db8500-prcmu, mt6397-core, cs5535-mfd
   - Only allocate IRQs on request; max77620
   - Use simplified API; arizona-core
   - Remove redundant and/or duplicated code; wm8998-tables, arizona,
     syscon
   - Device Tree binding fix-ups; madera, max77650, max77693
   - Remove mfd_cell->id abuse hack; cs5535-mfd
   - Remove only user of mfd_clone_cell(); cs5535-mfd
   - Make resources static; rohm-bd70528

  Bug Fixes:
   - Fix product ID for RK818; rk808
   - Fix Power Key; rk808
   - Fix booting on the BananaPi; mt6397-core
   - Endian fix-ups; twl.h
   - Fix static error checker warnings; ti_am335x_tscadc"

* tag 'mfd-next-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (47 commits)
  Revert "mfd: syscon: Set name of regmap_config"
  mfd: ti_am335x_tscadc: Fix static checker warning
  mfd: bd70528: Staticize bit value definitions
  mfd: mfd-core: Honour Device Tree's request to disable a child-device
  dt-bindings: mfd: max77693: Fix missing curly brace
  mfd: intel-lpss: Add Intel Comet Lake PCH-H PCI IDs
  mfd: db8500-prcmu: Support U8420-sysclk firmware
  dt-bindings: mfd: max77650: Convert the binding document to yaml
  mfd: mfd-core: Move pdev->mfd_cell creation back into mfd_add_device()
  mfd: mfd-core: Remove usage counting for .{en,dis}able() call-backs
  x86: olpc-xo1-sci: Remove invocation of MFD's .enable()/.disable() call-backs
  x86: olpc-xo1-pm: Remove invocation of MFD's .enable()/.disable() call-backs
  mfd: mfd-core: Remove mfd_clone_cell()
  mfd: mfd-core: Protect against NULL call-back function pointer
  mfd: cs5535-mfd: Register clients using their own dedicated MFD cell entries
  mfd: cs5535-mfd: Request shared IO regions centrally
  mfd: cs5535-mfd: Remove mfd_cell->id hack
  mfd: cs5535-mfd: Use PLATFORM_DEVID_* defines and tidy error message
  mfd: intel_soc_pmic_crc: Add "cht_crystal_cove_pmic" cell to CHT cells
  mfd: madera: Add support for requesting the supply clocks
  ...
2019-12-01 16:16:31 -08:00
Krzysztof Kozlowski
2a0efc7773 power: avs: Fix Kconfig indentation
Adjust indentation from spaces to tab (+optional two spaces) as in
coding style with command like:
	$ sed -e 's/^        /\t/' -i */Kconfig

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-29 11:53:36 +01:00
Linus Torvalds
00074a7007 power supply and reset changes for the v5.5 series
Drivers:
  * test_power: add support for current and charge_counter
  * cpcap-charger: improve charge calculation and limit default charge voltage
  * ab8500: convert to IIO
  * misc. small fixes all over drivers
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAl3dFBkACgkQ2O7X88g7
 +ppUPQ/7Bv3GRusMB9Z/nTlhTLyR68P5vOoQ7Axfhi9NUCIq3RRG/pKZkYKKits1
 5U9Z13pceDznmWvamPvNkhH6mVjS4JsLsJOSkp8op2DvptQpcrfs5t+XhBamWu/D
 pmy6FkhbFLhxSRshd3st1VcqPZNc9/PmoYaoBp397wDF+SKZxJ+wI/Fm6LQmqG/q
 SZv8eBKFmViyv+xYmXGJf2CZanxzZ0DZK2ZMYlp39XQcfOw90ImD5crZJcLlf9zQ
 HJV69JxurCDb0ovr2JfRjYtyfx8eqYFxSE5o6rqqNWIPGikQs3+TajovMuO5B0D0
 FmLxkgMeNAzK1CzccxKKh1qQi65T8Kdv+N6pgVgsR9wVfCmLsfYCeBrZb4PJv5GH
 hlJSZXxzYKgN00bD/7HA2l0hlUpIepQm0EtNCyjiPwGMVAHr8MerCfHwbzr5oWfq
 h1G3hGW9OOm1BwVvScff08UdL2xI6A7Aa7lLXqCkwM3oXhdFPAmr3qiv0Rw8wVNS
 /LY1HiQ2jldWgdVPdSMvPoLqxdfebz/Ro0J7do2amPGj/ebh6H7GvUVIxX/8cNZe
 iz22kzoJXW+k9173FGNZA+4Ccf49XdplFn2uinX9TsNCf4XCKcyWq+3aPczQ6zSl
 ZPqGn4mOpjRLm3xl/DbOOWXpNqFszVHhhX4G/WAMB8RMseFfelw=
 =iHhO
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - test_power: add support for current and charge_counter

 - cpcap-charger: improve charge calculation and limit default charge
   voltage

 - ab8500: convert to IIO

 - misc small fixes all over drivers

* tag 'for-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (29 commits)
  power: supply: bd70528: Add MODULE_ALIAS to allow module auto loading
  power: supply: ab8500_charger: Fix inconsistent IS_ERR and PTR_ERR
  power: supply: cpcap-charger: cpcap_charger_voltage_to_regval() can be static
  power: supply: cpcap-battery: Add basic coulomb counter calibrate support
  power: supply: cpcap-battery: Read and save integrator register CCI
  power: supply: cpcap-battery: Simplify short term power average calculation
  power: supply: cpcap-battery: Simplify coulomb counter calculation with div_s64
  power: supply: cpcap-battery: Move coulomb counter units per lsb to ddata
  power: supply: cpcap-charger: Allow changing constant charge voltage
  power: supply: cpcap-battery: Fix handling of lowered charger voltage
  power: supply: cpcap-charger: Improve battery detection
  power: supply: cpcap-battery: Check voltage before orderly_poweroff
  power: supply: cpcap-charger: Limit voltage to 4.2V for battery
  power: supply: ab8500: Handle invalid IRQ from platform_get_irq_byname()
  power: supply: ab8500_fg: Do not free non-requested IRQs in probe's error path
  power: supply: ab8500: Cleanup probe in reverse order
  power: reset: at91: fix __le32 cast in reset code
  power: supply: abx500_chargalg: Fix code indentation
  mfd: Switch the AB8500 GPADC to IIO
  iio: adc: New driver for the AB8500 GPADC
  ...
2019-11-27 09:55:39 -08:00
Geert Uytterhoeven
aca32d7bcc power: avs: smartreflex: Remove superfluous cast in debugfs_create_file() call
There is no need to cast a typed pointer to a void pointer when calling
a function that accepts the latter.  Remove it, as the cast prevents
further compiler checks.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-11-13 11:23:51 +01:00
Matti Vaittinen
9480029fe5 power: supply: bd70528: Add MODULE_ALIAS to allow module auto loading
The bd70528 charger driver is probed by MFD driver. Add MODULE_ALIAS
in order to allow udev to load the module when MFD sub-device cell for
charger is added.

Fixes: f8c7f7ddd8 ("power: supply: Initial support for ROHM BD70528 PMIC charger block")
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-27 22:33:44 +01:00
Gustavo A. R. Silva
f457055a79 power: supply: ab8500_charger: Fix inconsistent IS_ERR and PTR_ERR
Fix inconsistent IS_ERR and PTR_ERR in ab8500_charger_probe().

The proper pointer to be passed as argument is di->adc_main_charger_c

This bug was detected with the help of Coccinelle.

Fixes: 97ab78bac5 ("power: supply: ab8500_charger: Convert to IIO ADC")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-27 22:33:07 +01:00
Josef Friedl
d28c74c107 power: reset: add driver for mt6323 poweroff
add poweroff driver for mt6323 and make Makefile and Kconfig-Entries

Suggested-by: Frank Wunderlich <frank-w@public-files.de>
Signed-off-by: Josef Friedl <josef.friedl@speed.at>
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Acked-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-10-24 09:03:56 +01:00
kbuild test robot
e3da2ce04e power: supply: cpcap-charger: cpcap_charger_voltage_to_regval() can be static
Add 'static' keyword to internal function as reported by sparse
using the following configuration:

make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

Fixes: d4ee021c41 ("power: supply: cpcap-charger: Limit voltage to 4.2V for battery")
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-21 10:43:41 +02:00
Tony Lindgren
0cb90f071f power: supply: cpcap-battery: Add basic coulomb counter calibrate support
This patch adds support for the coulomb counter calibration on init. We do
this by polling for now, and only add partial calibration done interrupt
support.

Then later on when we know for sure we have the calibration done interrupt
available in the device tree, we can switch to using the calibration done
interrupt.

Cc: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 20:48:59 +02:00
Tony Lindgren
b28ac41950 power: supply: cpcap-battery: Read and save integrator register CCI
We can simplify code in the later patches by reading and saving the
integrator register CCI. Let's also fix a comment typo for register range
naming while at it.

Cc: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 20:48:32 +02:00
Tony Lindgren
ac437c1c84 power: supply: cpcap-battery: Simplify short term power average calculation
We can use sign_extend32() here to simplify things. And let's fix the
comment for CCM register, that contains the calibration offset.

Cc: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 20:33:39 +02:00
Tony Lindgren
c59b3bad6f power: supply: cpcap-battery: Simplify coulomb counter calculation with div_s64
We can simplify cpcap_battery_cc_raw_div() with div_s64.

Cc: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 20:30:43 +02:00
Tony Lindgren
458f5c8cda power: supply: cpcap-battery: Move coulomb counter units per lsb to ddata
We can simplify cpcap_battery_cc_raw_div() a bit by moving the units per
lsb to ddata.

Cc: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 20:27:10 +02:00
Tony Lindgren
5688ea0492 power: supply: cpcap-charger: Allow changing constant charge voltage
Let's allow reconfiguring the cpcap-charger max charge voltage and
default to 4.2V that should be safe for the known users.

This allows the users to use 4.35V for the extra capacity if really
needed at a cost of probably shorter battery life. We check the
constant charge voltage limit set by the battery.

Some pieces of the property setting code is based on an earlier patch
from Pavel Machek <pavel@ucw.cz> but limited to configuring the charge
voltage for now.

Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 20:26:23 +02:00
Tony Lindgren
8b0134cc14 power: supply: cpcap-battery: Fix handling of lowered charger voltage
With cpcap-charger now using 4.2V instead of 4.35V, we never reach
POWER_SUPPLY_CAPACITY_LEVEL_FULL unless we handle the lowered charge
voltage.

Let's do this by implementing POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
and assume anything at that level or higher is a full battery.

Let's also make it configurable for users who may still want to
reconfigure it, and notify the charger if supported by the charger.

Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 20:26:20 +02:00
Tony Lindgren
50fc99f83f power: supply: cpcap-charger: Improve battery detection
We are currently using a wrong ADC range for the battery detection.
The ADC returns the battery temperature if connected.

Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 20:26:17 +02:00
Tony Lindgren
639c1524da power: supply: cpcap-battery: Check voltage before orderly_poweroff
We can get the low voltage interrupt trigger sometimes way too early,
maybe because of CPU load spikes. This causes orderly_poweroff() be
called too easily.

Let's check the voltage before orderly_poweroff in case it was not
yet a permanent condition. We will be getting more interrupts anyways
if the condition persists.

Let's also show the measured voltages for low battery and battery
empty warnings since we have them.

Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 20:26:14 +02:00
Sebastian Reichel
8bc8fc088b Immutable branch between arm and power-supply for cpcap-charger
This immutable branch contains CPCAP charger changes, which
 touch ARM and power-supply subsystem.
 
 Signed-off-by: Sebastian Reichel <sre@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAl2splkACgkQ2O7X88g7
 +pp4WQ/9FE28GAkDDFajfVugAjPm5RcIIhHv0Hw7OXPxolKFNB24xbDe6AT1V7sn
 NLzwnHp9Ra8xxwXY4FsbG1i0KLzJIimPrzhLbYf3NkIZ+s/z/7GdzY5mKPImgWIy
 7cP/2+Zo3tSWFK4njxgecPUoi8fkAZKnEfiJDn9TgQ6aZ6ZN6koRAx33ZkbDyXYl
 CWXFHmxnVCoskyzmPQhWJW8D96lmOgJEt2Dpao/Vn2QhQFY2m+VQjkq73DNTGlDM
 6yT1hf+M8jTWMUQV6CEJfc6g6D0g/a6TCJ6hXihdiA0dF/ZhqACImpQxh5hPbZ6R
 iuR1ojqM4hv/mR9EoLTJWIvL5zEwmT/3UCXjbDjrSFJsYFe+9h1x9PissNcgui2j
 o1r/GDwKgQTQ54Kve/AS9Tjv1p6dqTzJmWCqE5fPIqZSc7WpQ9n0TZXuUXY/HQfy
 7c8kPbgPeoI9QbR8KdeajaZD7kiFecQEpsGp15aYXdnAYkFtxcWYZIZgrwQ4tm58
 I5hDf53ABsrl1ALJuC+FUX1Mjz4C7hyWtxuS1udBAYgt+bEjx3LbsSPegcjTXad2
 F2Ue+9SpHdZMD25i7CCBch0eA6Ko+3YAJkzDaCtK3t4wRTEJneCxxwXOMc564ktf
 VWeK2F5ASHMeft8Yml7oOu/4SkRo6lJ4/Bwcpz75Cf0la6WWUSE=
 =Nbmd
 -----END PGP SIGNATURE-----

Merge tag 'psy-cpcap-charge-volt-limit-signed' into psy-next

Immutable branch between arm and power-supply for cpcap-charger

This immutable branch contains CPCAP charger changes, which
touch ARM and power-supply subsystem.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
2019-10-20 20:24:59 +02:00
Tony Lindgren
d4ee021c41 power: supply: cpcap-charger: Limit voltage to 4.2V for battery
There have been some cases of droid4 battery bulging that seem to be
related to being left connected to the charger for several weeks.

It is suspected that the 4.35V charge voltage configured for the battery
is too much in the long run, so lets limit the charge voltage to 4.2V.
It could also be that the batteries are just getting old.

We don't really want to just change the charge voltage to 4.2V as Android
may have charged the battery to 4.35V as pointed out by Pavel Machek.

To add checks for battery voltage, the driver needs to understand the
voltage it's charging at, and also needs to better understand it's
charger state. Right now it only understands connect and disconnect,
while now we need to know also a connected state but not charging.

So let's add better charger state handling with help of chrgcurr2 interrupt
for detecting charge full and retry, and add a check for battery voltage
before we start charging. And then we finally can lower the charge voltage
to 4.2V.

Note that we've been using the same register values as the Android distros
on droid4, so it is suspected that the same problem also exists in Android.

Cc: Pavel Machek <pavel@ucw.cz>
Cc: Rob Herring <robh+dt@kernel.org>
Reported-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 19:10:39 +02:00
Krzysztof Kozlowski
b10e97003d power: supply: ab8500: Handle invalid IRQ from platform_get_irq_byname()
platform_get_irq_byname() might return -errno which later would be
cast to an unsigned int and used in request_irq().

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 15:18:44 +02:00
Krzysztof Kozlowski
2410899327 power: supply: ab8500_fg: Do not free non-requested IRQs in probe's error path
When requesting interrupt fails, free only interrupts already requested,
not all of them.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 15:18:08 +02:00
Krzysztof Kozlowski
ccc023a581 power: supply: ab8500: Cleanup probe in reverse order
It is logical to cleanup in probe's error path in reverse order to
previous actions.  It also makes easier to add additional goto labels
within this error path.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 15:17:15 +02:00
Sebastian Reichel
1a18f7e26a Merge remote-tracking branch 'ib-ab8500-5.4-rc1' into for-next
Merge immutable branch from IIO subsystem for driver
changes in ab8500_btemp, ab8500_charger and ab8500_fg.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
2019-10-20 15:14:14 +02:00
Ben Dooks (Codethink)
c045006420 power: reset: at91: fix __le32 cast in reset code
The writel() takes standard integers, not __le32 so
fix the following sparse warnings by removing the
cpu_to_le32() calls.

drivers/power/reset/at91-reset.c:134:9: warning: cast from restricted __le32
drivers/power/reset/at91-reset.c:143:9: warning: cast from restricted __le32

This has made no code changes, the md5sums pre and post applying
this patch are the same. The at91 should be natively little endian
anyway.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 15:04:13 +02:00
Madhuparna Bhowmik
bffc687cc6 power: supply: abx500_chargalg: Fix code indentation
Fixed Code indentation error caused due to using spaces
instead of tabs.

The error reported by checkpatch.pl is:
 ERROR: code indent should use tabs where possible

The warning reported by checkpatch.pl is:
 WARNING: please, no spaces at the start of a line

Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik04@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20 14:54:31 +02:00
Linus Walleij
1e82623c3c power: supply: ab8500_fg: Convert to IIO ADC
This switches the AB8500 fuel gauge driver to using
the standard IIO ADC channel lookup and conversion routines.

Acked-by: Sebastian Reichel <sre@kernel.org>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-18 19:37:03 +01:00
Linus Walleij
97ab78bac5 power: supply: ab8500_charger: Convert to IIO ADC
This switches the AB8500 battery charger driver to using
the standard IIO ADC channel lookup and conversion routines.

Acked-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-18 19:36:57 +01:00
Linus Walleij
0a8686e309 power: supply: ab8500_btemp: Convert to IIO ADC
This switches the AB8500 battery temperature driver to using
the standard IIO ADC channel lookup and conversion routines.

Acked-by: Sebastian Reichel <sre@kernel.org>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-18 19:36:48 +01:00
Icenowy Zheng
f2e5c49d22 power: supply: axp20x_usb_power: enable USB BC detection on AXP813
The AXP813 PMIC has support for detection of USB Battery Charging
specification, and it will limit the current to 500mA by default when
the detection is not enabled or the detection result is SDP.

Enable the BC detection to allow correctly selection of the current.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-14 06:19:53 +02:00
Claudiu Beznea
b0ac8596ed power: reset: at91-poweroff: lookup for proper PMC DT node
Driver has been enabled also for SAM9X60. At the moment the patch which did
this has been sent to mainline the PMC for SAM9X60 wasn't integrated.
SAM9X60 has a new PMC compatible (see commit 01e2113de9
("clk: at91: add sam9x60 pmc driver")). Do to this we have to
look for proper PMC compatible here, in SHDWC driver.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-10 18:42:56 +02:00
lecopzer@gmail.com
69318b3995 test_power: Add CURRENT properties
CURRENT is really general in other battery drivers,
Android also has an interface to monitor CURRENT, so let's
add it into test framework.

The default value (1.6A) is just a random but reasonable value.

Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-10 18:32:49 +02:00
lecopzer@gmail.com
4b082ac6b7 test_power: Add CHARGE_COUNTER properties
CHARGE_COUNTER is really general in other power supply drivers and
Android also has an interface to monitor CHARGE_COUNTER, so let's
add it into test framework.

Set default as -1000 is because the default status is
POWER_SUPPLY_STATUS_DISCHARGING, which means the counter should be
negative, and 1000 means not zero but small enough.

Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-10 18:32:48 +02:00
Linus Torvalds
619e17cf75 power supply and reset changes for the v5.4 series
Core:
  * Ensure HWMON devices are registered with valid names
  * Fix device wakeup code
 
 Drivers:
  * bq25890_charger: Add BQ25895 support
  * axp288_fuel_gauge: Add Minix Neo Z83-4 to blacklist
  * sc27xx: improve battery calibration
  * misc. small fixes all over drivers
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAl2HhCsACgkQ2O7X88g7
 +ppoKw//cPn+LOj1AJYGphqzMz207rJlgn7QFF0a0LhfQHdf6gPtrqVuZ1Mp9+RB
 +3aJqp6ORLpKEw7/x8IOlFVACwPRm+ikMqjchb3kYqMZCBuqmr0xYukzxvRWNf/K
 LIRkRWMETmaXj1KCIYdFyIt7Ff0HqlXZaFPrgCFK9DO6+wAgoE3LmgZXpya0h5ev
 PUYz8MnDjVd5+nkdBDpuBFvpsK66Lg0pZs5ScH1JUKrG6xoXEIU+7VeYJ7EEsfGE
 C54g0ZFYLGf+4zxeAyhg9sPb7/tzlM+SChZdUGk6bJ9txgWoalsfNxytb8huSfeK
 9dhTVMoZ9seBEq5mfJRUTnmQMRYpLJLWxJjz0MrQotOlSnIN73tlEpuIrUzWl0p7
 WIWkYu/hz+OOX0mBBngHXvnTWRQrjO+QIu9P23obFzBedtOL7LVqPtCd5FrJ48y3
 xQZAZUyyEUqhq2+HZaTn9HvTbFgnbHmWd/RQDarZcojC+836MlwWC7k3XqkfIa4i
 h3P/t6qyc/Kf7o5YT+/TkTpUR5yh2gSwfPGwTQH4hhOxPIN4prC7sF/oySm9tEgw
 qLZJ8XP0KuQpBEN8qdhd00bCwEEbDc4+qRJWyjjG0WN2my8BVlzKtrcAVCWspD15
 07TV84+OdIzvTXzgWUT1H47WG6RQfpX2rUSCtTwteh710beoctU=
 =cIXy
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:
 "Core:
   - Ensure HWMON devices are registered with valid names
   - Fix device wakeup code

  Drivers:
   - bq25890_charger: Add BQ25895 support
   - axp288_fuel_gauge: Add Minix Neo Z83-4 to blacklist
   - sc27xx: improve battery calibration
   - misc small fixes all over drivers"

* tag 'for-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (24 commits)
  power: supply: cpcap-charger: Enable vbus boost voltage
  power: supply: sc27xx: Add POWER_SUPPLY_PROP_CALIBRATE attribute
  power: supply: sc27xx: Optimize the battery capacity calibration
  power: supply: sc27xx: Make sure the alarm capacity is larger than 0
  power: supply: sc27xx: Fix the the accuracy issue of coulomb calculation
  power: supply: sc27xx: Fix conditon to enable the FGU interrupt
  power: supply: sc27xx: Add POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN attribute
  power: supply: max77650: add MODULE_ALIAS()
  power: supply: isp1704: remove redundant assignment to variable ret
  power: supply: bq25890_charger: Add the BQ25895 part
  power: supply: sc27xx: Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
  power: supply: sc27xx: Introduce local variable 'struct device *dev'
  power: reset: reboot-mode: Fix author email format
  power: supply: ab8500: remove set but not used variables 'vbup33_vrtcn' and 'bup_vch_range'
  power: supply: max17042_battery: Fix a typo in function names
  power: reset: gpio-restart: Fix typo when gpio reset is not found
  power: supply: Init device wakeup after device_add()
  power: supply: ab8500_charger: Mark expected switch fall-through
  power: supply: sbs-battery: only return health when battery present
  MAINTAINERS: N900: Remove isp1704_charger.h record
  ...
2019-09-22 12:04:59 -07:00
Linus Torvalds
5c6bd5de3c Main MIPS changes for v5.4:
- boot_mem_map is removed, providing a nice cleanup made possible by the
   recent removal of bootmem.
 
 - Some fixes to atomics, in general providing compiler barriers for
   smp_mb__{before,after}_atomic plus fixes specific to Loongson CPUs or
   MIPS32 systems using cmpxchg64().
 
 - Conversion to the new generic VDSO infrastructure courtesy of Vincenzo
   Frascino.
 
 - Removal of undefined behavior in set_io_port_base(), fixing the
   behavior of some MIPS kernel configurations when built with recent
   clang versions.
 
 - Initial MIPS32 huge page support, functional on at least Ingenic SoCs.
 
 - pte_special() is now supported for some configurations, allowing among
   other things generic fast GUP to be used.
 
 - Miscellaneous fixes & cleanups.
 
 And platform specific changes:
 
 - Major improvements to Ingenic SoC support from Paul Cercueil, mostly
   enabled by the inclusion of the new TCU (timer-counter unit) drivers
   he's spent a very patient year or so working on. Plus some fixes for
   X1000 SoCs from Zhou Yanjie.
 
 - Netgear R6200 v1 systems are now supported by the bcm47xx platform.
 
 - DT updates for BMIPS, Lantiq & Microsemi Ocelot systems.
 -----BEGIN PGP SIGNATURE-----
 
 iIsEABYIADMWIQRgLjeFAZEXQzy86/s+p5+stXUA3QUCXYaqpRUccGF1bC5idXJ0
 b25AbWlwcy5jb20ACgkQPqefrLV1AN2JUQD+PQGFIlq9bo/3vLyqsXJffm+DhwVQ
 4WSCSeN5brPkO8EA/153sRJBlRtG+KK5p9f7WYKUuBfbcEawuc1uwmKuy7cG
 =lWlM
 -----END PGP SIGNATURE-----

Merge tag 'mips_5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux

Pull MIPS updates from Paul Burton:
 "Main MIPS changes:

   - boot_mem_map is removed, providing a nice cleanup made possible by
     the recent removal of bootmem.

   - Some fixes to atomics, in general providing compiler barriers for
     smp_mb__{before,after}_atomic plus fixes specific to Loongson CPUs
     or MIPS32 systems using cmpxchg64().

   - Conversion to the new generic VDSO infrastructure courtesy of
     Vincenzo Frascino.

   - Removal of undefined behavior in set_io_port_base(), fixing the
     behavior of some MIPS kernel configurations when built with recent
     clang versions.

   - Initial MIPS32 huge page support, functional on at least Ingenic
     SoCs.

   - pte_special() is now supported for some configurations, allowing
     among other things generic fast GUP to be used.

   - Miscellaneous fixes & cleanups.

  And platform specific changes:

   - Major improvements to Ingenic SoC support from Paul Cercueil,
     mostly enabled by the inclusion of the new TCU (timer-counter unit)
     drivers he's spent a very patient year or so working on. Plus some
     fixes for X1000 SoCs from Zhou Yanjie.

   - Netgear R6200 v1 systems are now supported by the bcm47xx platform.

   - DT updates for BMIPS, Lantiq & Microsemi Ocelot systems"

* tag 'mips_5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: (89 commits)
  MIPS: Detect bad _PFN_SHIFT values
  MIPS: Disable pte_special() for MIPS32 with RiXi
  MIPS: ralink: deactivate PCI support for SOC_MT7621
  mips: compat: vdso: Use legacy syscalls as fallback
  MIPS: Drop Loongson _CACHE_* definitions
  MIPS: tlbex: Remove cpu_has_local_ebase
  MIPS: tlbex: Simplify r3k check
  MIPS: Select R3k-style TLB in Kconfig
  MIPS: PCI: refactor ioc3 special handling
  mips: remove ioremap_cachable
  mips/atomic: Fix smp_mb__{before,after}_atomic()
  mips/atomic: Fix loongson_llsc_mb() wreckage
  mips/atomic: Fix cmpxchg64 barriers
  MIPS: Octeon: remove duplicated include from dma-octeon.c
  firmware: bcm47xx_nvram: Allow COMPILE_TEST
  firmware: bcm47xx_nvram: Correct size_t printf format
  MIPS: Treat Loongson Extensions as ASEs
  MIPS: Remove dev_err() usage after platform_get_irq()
  MIPS: dts: mscc: describe the PTP ready interrupt
  MIPS: dts: mscc: describe the PTP register range
  ...
2019-09-22 09:30:30 -07:00
Linus Torvalds
32b90daf5c chrome platform changes for v5.4
* CrOS EC / MFD Migration
  - Move cros_ec core driver from mfd into chrome platform.
 
 * Wilco EC:
  - Add batt_ppid_info command to Wilco telemetry driver.
 
 * CrOS EC:
  - cros_ec_rpmsg : Add support to inform EC of suspend/resume status
  - cros_ec_rpmsg : Fix race condition on probe failed
  - cros_ec_chardev : Add a poll handler to receive MKBP events
 
 * Misc:
  - bugfixes in cros_usbpd_logger and cros_ec_ishtp
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQQCtZK6p/AktxXfkOlzbaomhzOwwgUCXYKpygAKCRBzbaomhzOw
 wlkXAP9QCKia7LiNujIl9kh7WXSloxdO0BzL93pgSpNHfUDeSAD+Mlcp+54bDqkB
 WaF2SR14Z2vzAFafroQTl6m41xJTog4=
 =slD7
 -----END PGP SIGNATURE-----

Merge tag 'tag-chrome-platform-for-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux

Pull chrome platform updates from Benson Leung:
 "CrOS EC / MFD Migration:
    - Move cros_ec core driver from mfd into chrome platform.

  Wilco EC:
    - Add batt_ppid_info command to Wilco telemetry driver.

  CrOS EC:
    - cros_ec_rpmsg : Add support to inform EC of suspend/resume status
    - cros_ec_rpmsg : Fix race condition on probe failed
    - cros_ec_chardev : Add a poll handler to receive MKBP events

  Misc:
    - bugfixes in cros_usbpd_logger and cros_ec_ishtp"

* tag 'tag-chrome-platform-for-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
  platform/chrome: cros_usbpd_logger: null check create_singlethread_workqueue
  platform/chrome: cros_ec_chardev: Add a poll handler to receive MKBP events
  platform/chrome: cros_ec_rpmsg: Fix race with host command when probe failed
  platform/chrome: chromeos_tbmc: Report wake events
  mfd: cros_ec: Use mfd_add_hotplug_devices() helper
  mfd: cros_ec: Add convenience struct to define autodetectable CrOS EC subdevices
  mfd: cros_ec: Add convenience struct to define dedicated CrOS EC MCUs
  mfd: cros_ec: Use kzalloc and cros_ec_cmd_xfer_status helper
  mfd / platform: cros_ec: Reorganize platform and mfd includes
  mfd / platform: cros_ec: Rename config to a better name
  mfd: cros_ec: Switch to use the new cros-ec-chardev driver
  mfd / platform: cros_ec: Miscellaneous character device to talk with the EC
  mfd / platform: cros_ec: Move cros-ec core driver out from MFD
  mfd / platform: cros_ec: Handle chained ECs as platform devices
  platform/chrome: cros_ec_rpmsg: Add host command AP sleep state support
  platform/chrome: chromeos_laptop: drop checks of NULL-safe functions
  platform/chrome: wilco_ec: Add batt_ppid_info command to telemetry driver
2019-09-19 14:14:28 -07:00
Tony Lindgren
7f7378618b power: supply: cpcap-charger: Enable vbus boost voltage
We are currently not enabling VBUS boost for cpcap when in host mode.
This means the VBUS is fed at the battery voltage level, which can cause
flakeyness enumerating devices.

Looks like the boost control for VBUS is CPCAP_BIT_VBUS_SWITCH that we
must enable in the charger for nice 4.92 V VBUS output. And looks like
we must not use the STBY pin enabling but must instead use manual VBUS
control in phy-cpcap-usb.

We want to do this in cpcap_charger_vbus_work() and also set a flag for
feeding_vbus to avoid races between USB detection and charger detection,
and disable charging if feeding_vbus is set.

Cc: Jacopo Mondi <jacopo@jmondi.org>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Marcel Partap <mpartap@gmx.net>
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Michael Scott <hashcode0f@gmail.com>
Cc: NeKit <nekit1000@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 23:08:07 +02:00
Yuanjiang Yu
7cfd33d997 power: supply: sc27xx: Add POWER_SUPPLY_PROP_CALIBRATE attribute
Add the 'POWER_SUPPLY_PROP_CALIBRATE' attribute to allow chareger manager
to calibrate the battery capacity.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 23:00:20 +02:00
Yuanjiang Yu
580665279f power: supply: sc27xx: Optimize the battery capacity calibration
This patch factors out the capacity calibration into one single function
to calibrate the battery capacity, and adding more abnormal cases to
calibrate the capacity when the OCV value is not matchable with current
capacity.

Moreover we also allow to calibrate the capacity when charger magager
tries to get current capacity to make sure we give a correct capacity
for userspace.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 22:59:50 +02:00
Yuanjiang Yu
ff062d0694 power: supply: sc27xx: Make sure the alarm capacity is larger than 0
We must make sure the alarm capacity is larger than 0, to help to
calibrate the low battery capacity.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 22:55:24 +02:00
Yuanjiang Yu
7384b0e766 power: supply: sc27xx: Fix the the accuracy issue of coulomb calculation
The Spreadtrum fuel gauge will multiply by 2 for counting the coulomb
counter to improve the accuracy, which means the value saved in fuel
gauge is: coulomb counter * 2 * 1000ma_adc. Thus fix the conversion
formular to improve the accuracy of calculating the battery capacity.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 22:49:49 +02:00
Yuanjiang Yu
168e68d072 power: supply: sc27xx: Fix conditon to enable the FGU interrupt
We should allow to enable FGU interrupt to adjust the battery capacity,
when charging status is POWER_SUPPLY_STATUS_DISCHARGING.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 22:47:09 +02:00
Yuanjiang Yu
7cff19b9a8 power: supply: sc27xx: Add POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN attribute
Add POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN attribute to provide the battery's
design capacity for charger manager to calculate the charging counter.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 22:44:34 +02:00
Bartosz Golaszewski
343160e98c power: supply: max77650: add MODULE_ALIAS()
Define a MODULE_ALIAS() in the charger sub-driver for max77650 so that
the appropriate module gets loaded together with the core mfd driver.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 21:15:45 +02:00
Colin Ian King
72e538f6ee power: supply: isp1704: remove redundant assignment to variable ret
The variable ret is being assigned with a value that is never
read and it is being updated later with a new value. The
assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 21:12:45 +02: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
Fuqian Huang
204205836f power: supply: sc27xx: Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
devm_add_action_or_reset() is introduced as a helper function which
internally calls devm_add_action(). If devm_add_action() fails
then it will execute the action mentioned and return the error code.
This reduce source code size (avoid writing the action twice)
and reduce the likelyhood of bugs.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Reviewed-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 21:09:12 +02:00
Fuqian Huang
08614b407d power: supply: sc27xx: Introduce local variable 'struct device *dev'
Introduce local variable 'struct device *dev' and use it instead of
dereferencing it repeatly.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Reviewed-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 21:08:43 +02:00
Matwey V. Kornilov
59857e9ead power: reset: reboot-mode: Fix author email format
Closing angle bracket was missing.

Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 21:05:59 +02:00
YueHaibing
9eab9a5b4c power: supply: ab8500: remove set but not used variables 'vbup33_vrtcn' and 'bup_vch_range'
Fixes gcc '-Wunused-but-set-variable' warnings:

drivers/power/supply/ab8500_charger.c:
 In function ab8500_charger_init_hw_registers:
drivers/power/supply/ab8500_charger.c:3013:24: warning:
 variable vbup33_vrtcn set but not used [-Wunused-but-set-variable]
drivers/power/supply/ab8500_charger.c:3013:5: warning:
 variable bup_vch_range set but not used [-Wunused-but-set-variable]

Fixes: 4c4268dc97 ("power: supply: ab8500: Drop AB8540/9540 support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 21:04:50 +02:00
Christophe JAILLET
40badfa396 power: supply: max17042_battery: Fix a typo in function names
It is likely that 'max10742_[un]lock_model()' functions should be
'max17042_[un]lock_model()'
(0 and 7 switched in 10742)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 21:02:43 +02:00
Michal Simek
0e063317d5 power: reset: gpio-restart: Fix typo when gpio reset is not found
Trivial patch which just corrects error message.

Fixes: 371bb20d69 ("power: Add simple gpio-restart driver")
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 20:32:23 +02:00
Enric Balletbo i Serra
840d9f131f mfd / platform: cros_ec: Reorganize platform and mfd includes
There is a bit of mess between cros-ec mfd includes and platform
includes. For example, we have a linux/mfd/cros_ec.h include that
exports the interface implemented in platform/chrome/cros_ec_proto.c. Or
we have a linux/mfd/cros_ec_commands.h file that is non related to the
multifunction device (in the sense that is not exporting any function of
the mfd device). This causes crossed includes between mfd and
platform/chrome subsystems and makes the code difficult to read, apart
from creating 'curious' situations where a platform/chrome driver includes
a linux/mfd/cros_ec.h file just to get the exported functions that are
implemented in another platform/chrome driver.

In order to have a better separation on what the cros-ec multifunction
driver does and what the cros-ec core provides move and rework the
affected includes doing:

 - Move cros_ec_commands.h to include/linux/platform_data/cros_ec_commands.h
 - Get rid of the parts that are implemented in the platform/chrome/cros_ec_proto.c
   driver from include/linux/mfd/cros_ec.h to a new file
   include/linux/platform_data/cros_ec_proto.h
 - Update all the drivers with the new includes, so
   - Drivers that only need to know about the protocol include
     - linux/platform_data/cros_ec_proto.h
     - linux/platform_data/cros_ec_commands.h
   - Drivers that need to know about the cros-ec mfd device also include
     - linux/mfd/cros_ec.h

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Series changes: 3
- Fix dereferencing pointer to incomplete type 'struct cros_ec_dev' (lkp)
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-09-02 11:33:42 +01:00
Enric Balletbo i Serra
47f11e0b40 mfd / platform: cros_ec: Move cros-ec core driver out from MFD
Now, the ChromeOS EC core driver has nothing related to an MFD device, so
move that driver from the MFD subsystem to the platform/chrome subsystem.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-09-02 11:33:12 +01:00
Stephen Boyd
8288022284 power: supply: Init device wakeup after device_add()
We may want to use the device pointer in device_init_wakeup() with
functions that expect the device to already be added with device_add().
For example, if we were to link the device initializing wakeup to
something in sysfs such as a class for wakeups we'll run into an error.
It looks like this code was written with the assumption that the device
would be added before initializing wakeup due to the order of operations
in power_supply_unregister().

Let's change the order of operations so we don't run into problems here.

Fixes: 948dcf9662 ("power_supply: Prevent suspend until power supply events are processed")
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tri Vo <trong@android.com>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: Ravi Chandra Sadineni <ravisadineni@chromium.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 10:06:31 +02:00
Gustavo A. R. Silva
1094806116 power: supply: ab8500_charger: Mark expected switch fall-through
Mark switch cases where we are expecting to fall through.

This patch fixes the following warning (Building: allmodconfig arm):

drivers/power/supply/ab8500_charger.c:738:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 10:06:31 +02:00
Michael Nosthoff
fe55e77032 power: supply: sbs-battery: only return health when battery present
when the battery is set to sbs-mode and  no gpio detection is enabled
"health" is always returning a value even when the battery is not present.
All other fields return "not present".
This leads to a scenario where the driver is constantly switching between
"present" and "not present" state. This generates a lot of constant
traffic on the i2c.

This commit changes the response of "health" to an error when the battery
is not responding leading to a consistent "not present" state.

Fixes: 76b16f4cdf ("power: supply: sbs-battery: don't assume MANUFACTURER_DATA formats")
Cc: <stable@vger.kernel.org>
Signed-off-by: Michael Nosthoff <committed@heine.so>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 10:06:31 +02:00
Michael Nosthoff
99956a9e08 power: supply: sbs-battery: use correct flags field
the type flag is stored in the chip->flags field not in the
client->flags field. This currently leads to never using the ti
specific health function as client->flags doesn't use that bit.
So it's always falling back to the general one.

Fixes: 76b16f4cdf ("power: supply: sbs-battery: don't assume MANUFACTURER_DATA formats")
Cc: <stable@vger.kernel.org>
Signed-off-by: Michael Nosthoff <committed@heine.so>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-02 10:06:23 +02:00
Hans de Goede
fa7da7449e power: supply: axp288_fuel_gauge: Add Minix Neo Z83-4 to the blacklist
The Minix Neo Z83-4 is another mini PC using the AXP288 PMIC where the
EFI code does not disable the charger part of the PMIC causing us to report
battery readings (of always 100%) to userspace even though there is no
battery in this wall-outlet powered device.

Add it to the blacklist to avoid the bogus battery status reporting.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-01 21:44:15 +02:00
Hans de Goede
6f3ed83471 power: supply: axp288_fuel_gauge: Sort the DMI blacklist alphabetically
The blacklist is getting big enough that it is good to have some sort
of fixed order for it, sort it alphabetically.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-01 21:44:15 +02:00
Romain Izard
f1b937cc86 power: supply: register HWMON devices with valid names
With the introduction of the HWMON compatibility layer to the power
supply framework in Linux 5.3, all power supply devices' names can be
used directly to create HWMON devices with the same names.

But HWMON has rules on allowable names that are different from those
used in the power supply framework. The dash character is forbidden, as
it is used by the libsensors library in userspace as a separator,
whereas this character is used in the device names in more than half of
the existing power supply drivers. This last case is consistent with the
typical naming usage with MFD and Device Tree.

This leads to warnings in the kernel log, with the format:

power_supply gpio-charger: hwmon: \
	'gpio-charger' is not a valid name attribute, please fix

Add a protection to power_supply_add_hwmon_sysfs() that replaces any
dash in the device name with an underscore when registering with the
HWMON framework. Other forbidden characters (star, slash, space, tab,
newline) are not replaced, as they are not in common use.

Fixes: e67d4dfc9f ("power: supply: Add HWMON compatibility layer")
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-09-01 21:43:04 +02:00
Gustavo A. R. Silva
5274fdba8e power: supply: ab8500_charger: Mark expected switch fall-through
Mark switch cases where we are expecting to fall through.

Fix the following warning (Building: allmodconfig arm):

drivers/power/supply/ab8500_charger.c: In function ‘ab8500_charger_max_usb_curr’:
drivers/power/supply/ab8500_charger.c:738:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (di->vbus_detected) {
      ^
drivers/power/supply/ab8500_charger.c:745:2: note: here
  case USB_STAT_HM_IDGND:
  ^~~~

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
2019-08-20 19:43:33 -05:00
Paul Cercueil
aea12071d6
power/supply: Drop obsolete JZ4740 driver
It has been replaced with the more mature ingenic-battery driver.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Tested-by: Artur Rojek <contact@artur-rojek.eu>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Paul Burton <paul.burton@mips.com>
2019-07-30 10:41:54 -07: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
Linus Torvalds
fb4da215ed pci-v5.3-changes
-----BEGIN PGP SIGNATURE-----
 
 iQJIBAABCgAyFiEEgMe7l+5h9hnxdsnuWYigwDrT+vwFAl0siFoUHGJoZWxnYWFz
 QGdvb2dsZS5jb20ACgkQWYigwDrT+vzi9A//S4jRyyZrgUr88Az0GbgMhE4b3yqc
 uL7om/Sf+443gG6C+aKkZSM/IE9hrbyIKuYq7GGxDkzZ/HkucZo2yIuAHkPgG4ik
 QQYJ8fJsmMq1bUht87c1ZZwGP0++Deq/Ns2+VNy/WBYqKLulnV0DvEEaJgPs9C5D
 ppwccGdo6UghiujBTpE4ddUBjFjjURWqT6wSnMRDQ4EGwfUhG0MWwwHKI4hbBuaL
 N6refuggdYyUUX5FeUOHa6VF6uTnSSAQ75k+40n4nljdayqoumHLskst77o9q5ZI
 oXjdpwgmuEqYhfp03HEA4Xo/bBxiRj76NuTiEMKvPokxjpanwbLrdV0GhF0OIlM0
 rp1NOI1w+vppFrU+rc2gtq+7hYXFmvdhjS29hFLeD91PP36N5d29jW5NVFpm7GCm
 n4TMGAOsu8RB+bNua6ZbZVcDk2EnPgQeIcM0ZPoBtPK19Fg/rScdEU4u/aFE1Y0Q
 C+Ks7D1qCvFpHzl/xAg0oo9v/jFsWef3qnQWOzot964Zz4W4NSVvB9Ox6Vbfj6C4
 v331LJmlPxG8fxBNA3q28FrTxcG1NW6sgo3WY9VoSp/vc0aqaPKhm7sbraTt5IrI
 TwqA/WhnAHv90MQCGFcofANyYTkjPkKk2QBFK6b0suoAmVdwVWWELi1WaZ+HdvgQ
 JP7YpmC2cXcQBPk=
 =ZGxL
 -----END PGP SIGNATURE-----

Merge tag 'pci-v5.3-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci

Pull PCI updates from Bjorn Helgaas:
 "Enumeration changes:

   - Evaluate PCI Boot Configuration _DSM to learn if firmware wants us
     to preserve its resource assignments (Benjamin Herrenschmidt)

   - Simplify resource distribution (Nicholas Johnson)

   - Decode 32 GT/s link speed (Gustavo Pimentel)

  Virtualization:

   - Fix incorrect caching of VF config space size (Alex Williamson)

   - Fix VF driver probing sysfs knobs (Alex Williamson)

  Peer-to-peer DMA:

   - Fix dma_virt_ops check (Logan Gunthorpe)

  Altera host bridge driver:

   - Allow building as module (Ley Foon Tan)

  Armada 8K host bridge driver:

   - add PHYs support (Miquel Raynal)

  DesignWare host bridge driver:

   - Export APIs to support removable loadable module (Vidya Sagar)

   - Enable Relaxed Ordering erratum workaround only on Tegra20 &
     Tegra30 (Vidya Sagar)

  Hyper-V host bridge driver:

   - Fix use-after-free in eject (Dexuan Cui)

  Mobiveil host bridge driver:

   - Clean up and fix many issues, including non-identify mapped
     windows, 64-bit windows, multi-MSI, class code, INTx clearing (Hou
     Zhiqiang)

  Qualcomm host bridge driver:

   - Use clk bulk API for 2.4.0 controllers (Bjorn Andersson)

   - Add QCS404 support (Bjorn Andersson)

   - Assert PERST for at least 100ms (Niklas Cassel)

  R-Car host bridge driver:

   - Add r8a774a1 DT support (Biju Das)

  Tegra host bridge driver:

   - Add support for Gen2, opportunistic UpdateFC and ACK (PCIe protocol
     details) AER, GPIO-based PERST# (Manikanta Maddireddy)

   - Fix many issues, including power-on failure cases, interrupt
     masking in suspend, UPHY settings, AFI dynamic clock gating,
     pending DLL transactions (Manikanta Maddireddy)

  Xilinx host bridge driver:

   - Fix NWL Multi-MSI programming (Bharat Kumar Gogada)

  Endpoint support:

   - Fix 64bit BAR support (Alan Mikhak)

   - Fix pcitest build issues (Alan Mikhak, Andy Shevchenko)

  Bug fixes:

   - Fix NVIDIA GPU multi-function power dependencies (Abhishek Sahu)

   - Fix NVIDIA GPU HDA enablement issue (Lukas Wunner)

   - Ignore lockdep for sysfs "remove" (Marek Vasut)

  Misc:

   - Convert docs to reST (Changbin Du, Mauro Carvalho Chehab)"

* tag 'pci-v5.3-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (107 commits)
  PCI: Enable NVIDIA HDA controllers
  tools: PCI: Fix installation when `make tools/pci_install`
  PCI: dwc: pci-dra7xx: Fix compilation when !CONFIG_GPIOLIB
  PCI: Fix typos and whitespace errors
  PCI: mobiveil: Fix INTx interrupt clearing in mobiveil_pcie_isr()
  PCI: mobiveil: Fix infinite-loop in the INTx handling function
  PCI: mobiveil: Move PCIe PIO enablement out of inbound window routine
  PCI: mobiveil: Add upper 32-bit PCI base address setup in inbound window
  PCI: mobiveil: Add upper 32-bit CPU base address setup in outbound window
  PCI: mobiveil: Mask out hardcoded bits in inbound/outbound windows setup
  PCI: mobiveil: Clear the control fields before updating it
  PCI: mobiveil: Add configured inbound windows counter
  PCI: mobiveil: Fix the valid check for inbound and outbound windows
  PCI: mobiveil: Clean-up program_{ib/ob}_windows()
  PCI: mobiveil: Remove an unnecessary return value check
  PCI: mobiveil: Fix error return values
  PCI: mobiveil: Refactor the MEM/IO outbound window initialization
  PCI: mobiveil: Make some register updates more readable
  PCI: mobiveil: Reformat the code for readability
  dt-bindings: PCI: mobiveil: Change gpio_slave and apb_csr to optional
  ...
2019-07-15 20:44:49 -07:00
Linus Torvalds
8de262531f - Core Frameworks
- Set 'struct device' fwnode when registering a new device
 
  - New Drivers
    - Add support for ROHM BD70528 PMIC
 
  - New Device Support
    - Add support for LP87561 4-Phase Regulator to TI LP87565 PMIC
    - Add support for RK809 and RK817 to Rockchip RK808
    - Add support for Lid Angle to ChromeOS core
    - Add support for CS47L15 CODEC to Madera core
    - Add support for CS47L92 CODEC to Madera core
    - Add support for ChromeOS (legacy) Accelerometers in ChromeOS core
    - Add support for Add Intel Elkhart Lake PCH to Intel LPSS
 
  - New Functionality
    - Provide regulator supply information when registering; madera-core
    - Additional Device Tree support; lp87565, madera, cros-ec, rohm,bd71837-pmic
    - Allow over-riding power button press via Device Tree; rohm-bd718x7
    - Differentiate between running processors; cros_ec_dev
 
  - Fix-ups
    - Big header file update; cros_ec_commands.h
    - Split header per-subsystem; rohm-bd718x7
    - Remove superfluous code; menelaus, cs5535-mfd, cs47lXX-tables
    - Trivial; sorting, coding style; intel-lpss-pci
    - Only remove Power Off functionality if set locally; rk808
    - Make use for Power Off Prepare(); rk808
    - Fix spelling mistake in header guards; stmfx
    - Properly free IDA resources
    - SPDX fixups; cs47lXX-tables, madera
    - Error path fixups; hi655x-pmic
 
  - Bug Fixes
    - Add missing break in case() statement
    - Repair undefined behaviour when not initialising variables; arizona-core, madera-core
    - Fix reference to Device Tree documentation; madera
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAl0sLxgACgkQUa+KL4f8
 d2E25Q/9HmDJIdfyDQg0xv5IM5HS1WsP9BcJCEgoRIsad4mMDRYt+ZeLbslwMhue
 E9tsFH359gGvyqR+7d6hPpEUET1UEcJy4eRD1zAc0+epllQTDHSy8oHt1dtH+8xB
 2AU5rvAKOqBk83D+V2Hkx2KcroWEQQNYIoR9/12Pi3xmEB1uaCO0/Ajd3B28bIBM
 Tzi3cVQ3U7jY9EIM44GVTsjDAbMSkQR0iab6cQF0vJAWaUmGKlsO7iRrU1XkN69V
 qXyBauI8WGiGssihrE8r+jYvHvmg7hA9OKZIckUaMXD/k7kpHbwIaFRh7gukq4Re
 Q6Cy30NfVJ1tY66/5oqN6gj5znfeuEudMCCzYAkzlROSp5eApe2Ke5ajYn3kOCZd
 ZKcsrw9Fiox1lKmuWXDbyf0nqf4zwdDPAnShRWaaF5aipwgywyGcwSigVtK4F0P5
 Hjc5RLv7GjTAJq+ZzwgKyAdtx8L0mhdLd1ZTQpEXk/g/E9dW4GF72hWj9TQ/9BnA
 ZflKv8aP3lDGRHgO3Huwi4lMzskB8BVCQMCFwLwGs5cY1oZQhAjTdJzBZjTGexhC
 evuuA8OUsCrOWMvnZf3saSdHJ1iMHtfPnqEGHRJQtNj4fFaXv80LasIomvvfJc1/
 9JlRyAgm2pF7YDrgTh65ZzBb324eKSZZoAj9XZbnTyzxUAcF69A=
 =A3jw
 -----END PGP SIGNATURE-----

Merge tag 'mfd-next-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
 "Core Frameworks:
   - Set 'struct device' fwnode when registering a new device

  New Drivers:
   - Add support for ROHM BD70528 PMIC

  New Device Support:
   - Add support for LP87561 4-Phase Regulator to TI LP87565 PMIC
   - Add support for RK809 and RK817 to Rockchip RK808
   - Add support for Lid Angle to ChromeOS core
   - Add support for CS47L15 CODEC to Madera core
   - Add support for CS47L92 CODEC to Madera core
   - Add support for ChromeOS (legacy) Accelerometers in ChromeOS core
   - Add support for Add Intel Elkhart Lake PCH to Intel LPSS

  New Functionality:
   - Provide regulator supply information when registering; madera-core
   - Additional Device Tree support; lp87565, madera, cros-ec, rohm,bd71837-pmic
   - Allow over-riding power button press via Device Tree; rohm-bd718x7
   - Differentiate between running processors; cros_ec_dev

  Fix-ups:
   - Big header file update; cros_ec_commands.h
   - Split header per-subsystem; rohm-bd718x7
   - Remove superfluous code; menelaus, cs5535-mfd, cs47lXX-tables
   - Trivial; sorting, coding style; intel-lpss-pci
   - Only remove Power Off functionality if set locally; rk808
   - Make use for Power Off Prepare(); rk808
   - Fix spelling mistake in header guards; stmfx
   - Properly free IDA resources
   - SPDX fixups; cs47lXX-tables, madera
   - Error path fixups; hi655x-pmic

  Bug Fixes:
   - Add missing break in case() statement
   - Repair undefined behaviour when not initialising variables; arizona-core, madera-core
   - Fix reference to Device Tree documentation; madera"

* tag 'mfd-next-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (45 commits)
  mfd: hi655x-pmic: Fix missing return value check for devm_regmap_init_mmio_clk
  mfd: madera: Fixup SPDX headers
  mfd: madera: Remove some unused registers and fix some defaults
  mfd: intel-lpss: Release IDA resources
  mfd: intel-lpss: Add Intel Elkhart Lake PCH PCI IDs
  mfd: cs5535-mfd: Remove ifdef OLPC noise
  mfd: stmfx: Fix macro definition spelling
  dt-bindings: mfd: Add link to ROHM BD71847 Datasheet
  MAINAINERS: Swap words in INTEL PMIC MULTIFUNCTION DEVICE DRIVERS
  mfd: cros_ec_dev: Register cros_ec_accel_legacy driver as a subdevice
  mfd: rk808: Prepare rk805 for poweroff
  mfd: rk808: Check pm_power_off pointer
  mfd: cros_ec: differentiate SCP from EC by feature bit
  dt-bindings: Add binding for cros-ec-rpmsg
  mfd: madera: Add Madera core support for CS47L92
  mfd: madera: Add Madera core support for CS47L15
  mfd: madera: Update DT bindings to add additional CODECs
  mfd: madera: Add supply mapping for MICVDD
  mfd: madera: Fix potential uninitialised use of variable
  mfd: madera: Fix bad reference to pinctrl.txt file
  ...
2019-07-15 20:18:40 -07:00
Linus Torvalds
5516745311 platform-drivers-x86 for v5.3-1
ASUS WMI driver got a big refactoring in order to support the TUF Gaming
 laptops. Besides that, the regression with backlight being permanently off
 on various EeePC laptops has been fixed.
 
 Accelerometer on HP ProBook 450 G0 shows wrong measurements due to
 X axis being inverted. This has been fixed.
 
 Intel PMC core driver has been extended to be ACPI enumerated
 if the DSDT provides device with _HID "INT33A1". This allows
 to convert the driver to be pure platform and support new hardware
 purely based on ACPI DSDT.
 
 From now on the Intel Speed Select Technology is supported thru
 a corresponding driver. This driver provides an access to the features
 of the ISST, such as Performance Profile, Core Power, Base frequency and
 Turbo Frequency.
 
 Mellanox platform drivers has been refactored and now extended
 to support more systems, including new coming ones.
 
 The OLPC XO-1.75 platform is now supported.
 
 CB4063 Beckhoff Automation board is using PMC clocks,
 provided via pmc_atom driver, for ethernet controllers in a way
 that they can't be managed by the clock driver. The quirk
 has been extended to cover this case.
 
 Touchscreen on Chuwi Hi10 Plus tablet has been enabled. Meanwhile
 the information of Chuwi Hi10 Air has been fixed to cover more models
 based on the same platform.
 
 Xiaomi notebooks have WMI interface enabled. Thus, the driver to support it
 has been provided. It required some extension of the generic WMI library,
 which allows to propagate opaque context to the ->probe() of the
 individual drivers.
 
 This release includes debugfs clean up from Greg KH for several drivers
 that drop return code check and make debugfs absence or failure non-fatal.
 
 Miscellaneous fixes here and there, mostly for Acer WMI and
 various Intel drivers.
 
 The listed below commits are duplicated due to previously pushed fixes in v5.2 cycle:
 - 1dd93f873d platform/x86: asus-wmi: Only Tell EC the OS will handle display hotkeys from asus_nb_wmi
 - 89ae3a0736 platform/x86: intel-vbtn: Report switch events when event wakes device
 - fa882fc80d platform/x86: mlx-platform: Fix parent device in i2c-mux-reg device registration
 - 0bfcd24b39 platform/mellanox: mlxreg-hotplug: Add devm_free_irq call to remove flow
 
 The following is an automated git shortlog grouped by driver:
 
 acer-wmi:
  -  Mark expected switch fall-throughs
  -  no need to check return value of debugfs_create functions
 
 asus-nb-wmi:
  -  Add microphone mute key code
 
 asus-wmi:
  -  Use dev_get_drvdata()
  -  Do not disable keyboard backlight on unloading
  -  Switch fan boost mode
  -  Enhance detection of thermal data
  -  Organize code into sections
  -  Refactor error handling
  -  Support WMI event queue
  -  Refactor WMI event handling
  -  Improve DSTS WMI method ID detection
  -  Increase input buffer size of WMI methods
  -  Fix preserving keyboard backlight intensity on load
  -  Fix hwmon device cleanup
  -  no need to check return value of debugfs_create functions
  -  Only Tell EC the OS will handle display hotkeys from asus_nb_wmi
 
 dell-laptop:
  -  no need to check return value of debugfs_create functions
 
 hp_accel:
  -  Add support for HP ProBook 450 G0
 
 ideapad-laptop:
  -  no need to check return value of debugfs_create functions
 
 intel_int0002_vgpio:
  -  Get rid of custom ICPU() macro
 
 intel_menlow:
  -  avoid null pointer deference error
 
 intel_pmc:
  -  no need to check return value of debugfs_create functions
 
 intel_pmc_core:
  -  Attach using APCI HID "INT33A1"
  -  transform Pkg C-state residency from TSC ticks into microseconds
 
 intel_telemetry:
  -  no need to check return value of debugfs_create functions
 
 intel-vbtn:
  -  Report switch events when event wakes device
 
 ISST:
  -  Restore state on resume
  -  Add Intel Speed Select PUNIT MSR interface
  -  Add Intel Speed Select mailbox interface via MSRs
  -  Add Intel Speed Select mailbox interface via PCI
  -  Add Intel Speed Select mmio interface
  -  Add IOCTL to Translate Linux logical CPU to PUNIT CPU number
  -  Store per CPU information
  -  Add common API to register and handle ioctls
  -  Update ioctl-number.txt for Intel Speed Select interface
  -  A tool to validate Intel Speed Select commands
  -  Add .gitignore file
 
 MAINTAINERS:
  -  Update for Intel Speed Select Technology
 
 mlx-platform:
  -  Fix error handling in mlxplat_init()
  -  Add more reset cause attributes
  -  Modify DMI matching order
  -  Add regmap structure for the next generation systems
  -  Change API for i2c-mlxcpld driver activation
  -  Move regmap initialization before all drivers activation
  -  Fix parent device in i2c-mux-reg device registration
  -  Add new attribute for mlxreg-io sysfs interfaces
 
 pcengines-apuv2:
  -  Make two symbols static
  -  Fix PCENGINES_APU2 Kconfig warning
 
 OLPC:
  -  Add a config menu category for XO 1.75
  -  Require CONFIG_POWER_SUPPLY for XO-1.75 EC
  -  Fix olpc_xo175_ec_cmd() return value
  -  Make olpc_dt_compatible_match() static __init
  -  Add INPUT dependencies
  -  Fix build error without CONFIG_SPI
  -  Add a regulator for the DCON
  -  Add XO-1.75 EC driver
  -  Use BIT() and GENMASK() for event masks
  -  Avoid a warning if the EC didn't register yet
  -  Move EC-specific functionality out from x86
  -  Remove an unused include
  -  Add OLPC XO-1.75 EC bindings
 
 platform/mellanox:
  -  mlxreg-hotplug: Add devm_free_irq call to remove flow
 
 pmc_atom:
  -  Add CB4063 Beckhoff Automation board to critclk_systems DMI table
  -  no need to check return value of debugfs_create functions
 
 Kconfig:
  - Remove left-over BACKLIGHT_LCD_SUPPORT
 
 samsung-laptop:
  -  no need to check return value of debugfs_create functions
 
 touchscreen_dmi:
  -  Update Hi10 Air filter
  -  Add info for the CHUWI Hi10 Plus tablet.
 
 wmi:
  -  add Xiaomi WMI key driver
  -  add context argument to the probe function
  -  add context pointer field to struct wmi_device_id
  -  Add function to get _UID of WMI device
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEqaflIX74DDDzMJJtb7wzTHR8rCgFAl0rP88ACgkQb7wzTHR8
 rCis8BAAnRgRgi8x1C7xn66gAUHsDXpY0tF9cp/Fw3HyTmFCQkRSmnLkMM2DqGi+
 dvB9U1zPcGWwdwryKFsJXioEK3erYpiYyT2VwLtW4S7P5jQ+N9biT4TZ8yFp0MEr
 MZC50LZDV1JTp1a0GQyrMpfoMBnE7UhR2GL8UbGli/WwXFE5BLkrJ1pdrjhYZOHl
 rJcgq3HPAhV5qkUkIU7gTC2GGSPydjBqk0OhVIU4dPsYwXIb2gXc0yR0QVwKm5x3
 I/NQwBOBMKmdI6uJ8BJyg/p888Strw65YJaTe5wtvG8ljuIbcN/aQ3ZmClNrUnc0
 58byqJCpRhg9HN39VpF9rsApEGxKTlitAUAUKy7lgue7/mycHbA1Syzz29AIM+2v
 ey2/zgFeeWtgh1cuh2cUWlCE6woW7ED4VpDxhkXlX4xGUp+CILEiFqcsULlcc4j5
 sgojCLRPs78roYj9Y84CwYbsd7J/Ce4r2evBpKYPqYxDbUiuH2aVQtEdPTKv9/xC
 yHtBuJJSxY7a+sf4OZONRo13dfvRoZIPjcccR8yTOakS2/1Fqph7MpHyDkwFAfeS
 M2f+OcJn9IECol1391PTLj9Dx3jApyVk21HJdiIj7sKZgJOSS54AFm0/Ywk0MFpY
 XScXKulV48SdL4ZKup5aIpDzyP5zuvXszKQboRitep1dHiR9bl0=
 =DC5j
 -----END PGP SIGNATURE-----

Merge tag 'platform-drivers-x86-v5.3-1' of git://git.infradead.org/linux-platform-drivers-x86

Pull x86 platform driver updates from Andy Shevchenko:
 "Gathered a bunch of x86 platform driver changes. It's rather big,
  since includes two big refactors and completely new driver:

   - ASUS WMI driver got a big refactoring in order to support the TUF
     Gaming laptops. Besides that, the regression with backlight being
     permanently off on various EeePC laptops has been fixed.

   - Accelerometer on HP ProBook 450 G0 shows wrong measurements due to
     X axis being inverted. This has been fixed.

   - Intel PMC core driver has been extended to be ACPI enumerated if
     the DSDT provides device with _HID "INT33A1". This allows to
     convert the driver to be pure platform and support new hardware
     purely based on ACPI DSDT.

   - From now on the Intel Speed Select Technology is supported thru a
     corresponding driver. This driver provides an access to the
     features of the ISST, such as Performance Profile, Core Power, Base
     frequency and Turbo Frequency.

   - Mellanox platform drivers has been refactored and now extended to
     support more systems, including new coming ones.

   - The OLPC XO-1.75 platform is now supported.

   - CB4063 Beckhoff Automation board is using PMC clocks, provided via
     pmc_atom driver, for ethernet controllers in a way that they can't
     be managed by the clock driver. The quirk has been extended to
     cover this case.

   - Touchscreen on Chuwi Hi10 Plus tablet has been enabled. Meanwhile
     the information of Chuwi Hi10 Air has been fixed to cover more
     models based on the same platform.

   - Xiaomi notebooks have WMI interface enabled. Thus, the driver to
     support it has been provided. It required some extension of the
     generic WMI library, which allows to propagate opaque context to
     the ->probe() of the individual drivers.

  This release includes debugfs clean up from Greg KH for several
  drivers that drop return code check and make debugfs absence or
  failure non-fatal.

  Also miscellaneous fixes here and there, mostly for Acer WMI and
  various Intel drivers"

* tag 'platform-drivers-x86-v5.3-1' of git://git.infradead.org/linux-platform-drivers-x86: (74 commits)
  platform/x86: Fix PCENGINES_APU2 Kconfig warning
  tools/power/x86/intel-speed-select: Add .gitignore file
  platform/x86: mlx-platform: Fix error handling in mlxplat_init()
  platform/x86: intel_pmc_core: Attach using APCI HID "INT33A1"
  platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds
  platform/x86: asus-wmi: Use dev_get_drvdata()
  Documentation/ABI: Add new attribute for mlxreg-io sysfs interfaces
  platform/x86: mlx-platform: Add more reset cause attributes
  platform/x86: mlx-platform: Modify DMI matching order
  platform/x86: mlx-platform: Add regmap structure for the next generation systems
  platform/x86: mlx-platform: Change API for i2c-mlxcpld driver activation
  platform/x86: mlx-platform: Move regmap initialization before all drivers activation
  MAINTAINERS: Update for Intel Speed Select Technology
  tools/power/x86: A tool to validate Intel Speed Select commands
  platform/x86: ISST: Restore state on resume
  platform/x86: ISST: Add Intel Speed Select PUNIT MSR interface
  platform/x86: ISST: Add Intel Speed Select mailbox interface via MSRs
  platform/x86: ISST: Add Intel Speed Select mailbox interface via PCI
  platform/x86: ISST: Add Intel Speed Select mmio interface
  platform/x86: ISST: Add IOCTL to Translate Linux logical CPU to PUNIT CPU number
  ...
2019-07-14 16:51:47 -07:00
Arnd Bergmann
caa2b55784 power: reset: nvmem-reboot-mode: add CONFIG_OF dependency
Without CONFIG_OF, we get a build failure in the reboot-mode
implementation:

drivers/power/reset/reboot-mode.c: In function 'reboot_mode_register':
drivers/power/reset/reboot-mode.c:72:2: error: implicit declaration of function 'for_each_property_of_node'; did you mean 'for_each_child_of_node'? [-Werror=implicit-function-declaration]
  for_each_property_of_node(np, prop) {

Add a Kconfig dependency like we have for the other users of
CONFIG_REBOOT_MODE.

Fixes: 7a78a7f769 ("power: reset: nvmem-reboot-mode: use NVMEM as reboot mode write interface")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-07-09 00:28:49 +02:00
Rafael J. Wysocki
13b06b78c7 Merge branches 'pm-opp', 'pm-misc', 'pm-avs' and 'pm-tools'
* pm-opp:
  opp: Don't use IS_ERR on invalid supplies
  opp: Make dev_pm_opp_set_rate() handle freq = 0 to drop performance votes
  opp: Don't overwrite rounded clk rate
  opp: Allocate genpd_virt_devs from dev_pm_opp_attach_genpd()
  opp: Attach genpds to devices from within OPP core

* pm-misc:
  PM / clk: Remove error message on out-of-memory condition
  drivers: base: power: clock_ops: Use of_clk_get_parent_count()

* pm-avs:
  power: avs: smartreflex: no need to check return value of debugfs_create functions

* pm-tools:
  cpupower : frequency-set -r option misses the last cpu in related cpu list
  cpupower: correct spelling of interval
  Add README and update pm-graph and sleepgraph docs
  Update to pm-graph 5.4
  Update to pm-graph 5.3
2019-07-08 10:59:38 +02:00
Nick Crews
3f57fe28f8 power_supply: wilco_ec: Add charging config driver
Add a driver to control the charging algorithm used on Wilco
devices. See Documentation/ABI/testing/sysfs-class-power-wilco
for the userspace interface and other info.

Signed-off-by: Nick Crews <ncrews@chromium.org>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-07-05 00:54:36 +02:00
Enric Balletbo i Serra
2ffb500d82 power: supply: cros: allow to set input voltage and current limit
This patch allows reading and writing the input voltage and current
limit through the POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT and
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT sysfs properties. This allows
userspace to see current values and to re-configure these values at
runtime based on system-level knowledge or user input.

By default there is no limit, this is reported as a -1 when reading from
userspace. Writing a value will set the current or voltage limit in uA
or uV, and writing any negative value will remove that limit.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-06-28 17:28:27 +02:00
Enric Balletbo i Serra
a4496d52b3 power: supply: add input power and voltage limit properties
For thermal management strategy you might be interested on limit the
input power for a power supply. We already have current limit but
basically what we probably want is to limit power. So, introduce the
input_power_limit property.

Although the common use case is limit the input power, in some
specific cases it is the voltage that is problematic (i.e some regulators
have different efficiencies at higher voltage resulting in more heat).
So introduce also the input_voltage_limit property.

This happens in one Chromebook and is used on the Pixel C's thermal
management strategy to effectively limit the input power to 5V 3A when
the screen is on. When the screen is on, the display, the CPU, and the GPU
all contribute more heat to the system than while the screen is off, and
we made a tradeoff to throttle the charger in order to give more of the
thermal budget to those other components.

So there's nothing fundamentally broken about the hardware that would
cause the Pixel C to malfunction if we were charging at 9V or 12V instead
of 5V when the screen is on, i.e. if userspace doesn't change this.

What would happen is that you wouldn't meet Google's skin temperature
targets on the system if the charger was allowed to run at 9V or 12V with
the screen on.

For folks hacking on Pixel Cs (which is now outside of Google's official
support window for Android) and customizing their own kernel and userspace
this would be acceptable, but we wanted to expose this feature in the
power supply properties because the feature does exist in the Emedded
Controller firmware of the Pixel C and all of Google's Chromebooks with
USB-C made since 2015 in case someone running an up to date kernel wanted
to limit the charging power for thermal or other reasons.

This patch exposes a new property, similar to input current limit, to
re-configure the maximum voltage from the external supply at runtime
based on system-level knowledge or user input.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-06-28 17:28:27 +02:00
Matti Vaittinen
f8c7f7ddd8 power: supply: Initial support for ROHM BD70528 PMIC charger block
ROHM BD70528 PMIC includes battery charger block. Support charger
staus queries and doing few basic settings like input current limit
and charging current.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-06-27 10:57:24 +01:00
kbuild test robot
89e7854fcd power: supply: fix semicolon.cocci warnings
drivers/power/supply/ucs1002_power.c:339:2-3: Unneeded semicolon

 Remove unneeded semicolon.

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

Fixes: 9a2688e426 ("power: supply: Add driver for Microchip UCS1002")
CC: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-06-26 21:56:52 +02:00
Han Nandor
7a78a7f769 power: reset: nvmem-reboot-mode: use NVMEM as reboot mode write interface
Add a new reboot mode write interface that is using an NVMEM cell
to store the reboot mode magic.

Signed-off-by: Nandor Han <nandor.han@vaisala.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-06-25 23:58:40 +02:00
John Stultz
fce5430f6a reset: qcom-pon: Add support for gen2 pon
Add support for gen2 pon register so "reboot bootloader" can
work on pixel3 and db845.

Cc: Andy Gross <agross@kernel.org>
Cc: David Brown <david.brown@linaro.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: devicetree@vger.kernel.org
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>

v2:
* Split out dts changes into separate path
* Minor cleanups and remove unused variables

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-06-24 23:26:32 +02:00
Andrey Smirnov
e67d4dfc9f power: supply: Add HWMON compatibility layer
Add code implementing HWMON adapter/compatibility layer to allow
expositing various sensors present on power supply devices via HWMON
subsystem. This is done in order to allow userspace to use single
ABI/library(libsensors) to access/manipulate all of the sensors of the
system.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Chris Healy <cphealy@gmail.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Cory Tusar <cory.tusar@zii.aero>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-06-23 19:47:48 +02:00
Wolfram Sang
22ee8384dc power: supply: sbs-manager: 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:03:26 +02:00
Wolfram Sang
bf0e482aef power: supply: rt9455_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:03:20 +02:00
Wolfram Sang
df324c606a power: supply: rt5033_battery: 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:03:11 +02:00
Wolfram Sang
dee2f3cf94 power: supply: max17042_battery: 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:03:02 +02:00
Wolfram Sang
4e9c406dbe power: supply: max17040_battery: 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:53 +02:00
Wolfram Sang
71d7ffb29b power: supply: max14656_charger_detector: 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:47 +02: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
Wolfram Sang
1c9427be2a power: supply: bq24257_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:17 +02:00
Wolfram Sang
37669d9ff5 power: supply: bq24190_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:09 +02:00
Thomas Gleixner
d2912cb15b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
Based on 2 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 version 2 as
  published by the free software foundation

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-19 17:09:55 +02:00
Thomas Gleixner
f71e7375c9 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 455
Based on 1 normalized pattern(s):

  this package is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 and
  only version 2 as published by the free software foundation

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Enrico Weigelt <info@metux.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081201.371541790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-19 17:09:09 +02:00
Greg Kroah-Hartman
8eb835e478 power: avs: smartreflex: no need to check return value of debugfs_create functions
When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

And even when not checking the return value, no need to cast away the
call to (void), as these functions were never a "must check" type of a
function, so remove that odd cast.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-06-18 10:54:32 +02:00
Mauro Carvalho Chehab
151f4e2bdc docs: power: convert docs to ReST and rename to *.rst
Convert the PM documents to ReST, in order to allow them to
build with Sphinx.

The conversion is actually:
  - add blank lines and indentation in order to identify paragraphs;
  - fix tables markups;
  - add some lists markups;
  - mark literal blocks;
  - adjust title markups.

At its new index.rst, let's add a :orphan: while this is not linked to
the main index.rst file, in order to avoid build warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Srivatsa S. Bhat (VMware) <srivatsa@csail.mit.edu>
2019-06-14 16:08:36 -05:00
Thomas Gleixner
d925da5c7b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 450
Based on 1 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 version 2 as
  published bythe free software foundation

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Armijn Hemel <armijn@tjaldur.nl>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190531190116.345887520@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:37:18 +02:00
Thomas Gleixner
2025cf9e19 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms and conditions of the gnu general public license
  version 2 as published by the free software foundation this program
  is distributed in the hope 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-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190529141901.208660670@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:36:37 +02:00
Thomas Gleixner
8e8e69d67e treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 285
Based on 1 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 version 2 of the license 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-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190529141900.918357685@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:36:37 +02:00
Thomas Gleixner
97fb5e8d9b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284
Based on 1 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 version 2 and
  only version 2 as published by the free software foundation 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-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190529141900.825281744@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:36:37 +02:00
Thomas Gleixner
9c92ab6191 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282
Based on 1 normalized pattern(s):

  this software is licensed under the terms of the gnu general public
  license version 2 as published by the free software foundation and
  may be copied distributed and modified under those terms 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-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190529141900.642774971@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:36:37 +02:00
Thomas Gleixner
a63a5fa97e treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 218
Based on 1 normalized pattern(s):

  you may use this code as per gpl version 2

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190528171439.762454146@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:29:54 -07:00
Thomas Gleixner
9952f6918d treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 201
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms and conditions of the gnu general public license
  version 2 as published by the free software foundation this program
  is distributed in the hope 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 you should have received a copy of the gnu general
  public license along with this program if not see http www gnu org
  licenses

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190528171438.107155473@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:29:52 -07:00
Thomas Gleixner
0376148f30 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 197
Based on 1 normalized pattern(s):

  license terms gnu general public license v2

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190528170027.724130665@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:29:22 -07:00
Thomas Gleixner
af873fcece treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194
Based on 1 normalized pattern(s):

  license terms gnu general public license gpl version 2

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190528170027.447718015@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:29:22 -07:00
Thomas Gleixner
fda8d26e61 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 177
Based on 1 normalized pattern(s):

  licensed under the gpl 2

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 135 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: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190528170026.071193225@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:29:19 -07:00
Thomas Gleixner
1802d0beec treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174
Based on 1 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 version 2 as
  published by the free software foundation 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-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070034.575739538@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:41 -07: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
Thomas Gleixner
1a59d1b8e0 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156
Based on 1 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 you
  should have received a copy of the gnu general public license along
  with this program if not write to the free software foundation inc
  59 temple place suite 330 boston ma 02111 1307 usa

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:35 -07:00
Thomas Gleixner
2874c5fd28 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
Based on 1 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

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:32 -07:00
Thomas Gleixner
a912e80bd0 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 151
Based on 1 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 you should have received a copy of the
  gnu general public license along with this program if not write to
  the free software foundation inc 675 mass ave cambridge ma 02139 usa

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Armijn Hemel <armijn@tjaldur.nl>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070032.655028468@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:26:28 -07:00
Thomas Gleixner
1621633323 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 1
Based on 2 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 you
  should have received a copy of the gnu general public license along
  with this program if not write to the free software foundation inc
  51 franklin street fifth floor boston ma 02110 1301 usa

  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 [no]_[pad]_[ctrl] 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 you should have received a copy of the gnu general
  public license along with this program if not write to the free
  software foundation inc 51 franklin street fifth floor boston ma
  02110 1301 usa

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Jilayne Lovejoy <opensource@jilayne.com>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190519154040.652910950@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-21 11:28:39 +02:00
Thomas Gleixner
ec8f24b7fa treewide: Add SPDX license identifier - Makefile/Kconfig
Add SPDX license identifiers to all Make/Kconfig files which:

 - Have no license information of any form

These files fall under the project license, GPL v2 only. The resulting SPDX
license identifier is:

  GPL-2.0-only

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-21 10:50:46 +02:00
Thomas Gleixner
09c434b8a0 treewide: Add SPDX license identifier for more missed files
Add SPDX license identifiers to all files which:

 - Have no license information of any form

 - Have MODULE_LICENCE("GPL*") inside which was used in the initial
   scan/conversion to ignore the file

These files fall under the project license, GPL v2 only. The resulting SPDX
license identifier is:

  GPL-2.0-only

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-21 10:50:45 +02:00
Lubomir Rintel
ef071bab65 power: supply: olpc_battery: Allow building the driver on non-x86
With the recent changes to the driver and addition of OLPC XO-1.75 EC
driver it is possible to use this driver on ARM-based XO laptops as
well.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2019-05-20 17:27:08 +03:00
Lubomir Rintel
ec9964b480 Platform: OLPC: Move EC-specific functionality out from x86
Move the olpc-ec driver away from the X86 OLPC platform so that it could be
used by the ARM based laptops too. Notably, the driver for the OLPC battery,
which is also used on the ARM models, builds on this driver's interface.

It is actually plaform independent: the OLPC EC commands with their argument
and responses are mostly the same despite the delivery mechanism is
different.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2019-05-20 17:27:08 +03:00
Linus Torvalds
8649efb2f8 power supply and reset changes for the v5.2 series
Core:
  * Add over-current health state
  * Add standard, adaptive and custom charge types
  * Add new properties for start/end charge threshold
 
 New Drivers / Hardware:
  * UCS1002 Programmable USB Port Power Controller
  * Ingenic JZ47xx Battery Fuel Gauge
  * AXP20x USB Power: Add AXP813 support
  * AT91 poweroff: Add SAM9X60 support
  * OLPC battery: Add XO-1.5 and XO-1.75 support
 
 Misc. Changes:
  * syscon-reboot: support mask property
  * AXP288 fuel gauge: Blacklist ACEPC T8/T11
   - Looks like some vendor thought it's a good idea to
     build a desktop system with a fuel gauge, that slowly
     "discharges"...
  * cpcap-battery: Fix calculation errors
  * misc. fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlzbPpUACgkQ2O7X88g7
 +ppU9w/9GDMAHh5LelpuKosuWfdoZMOiMqtyp+GH+Tg4t/cYksTpUFcupKE8sIEU
 HG+YHNZdD56rHYz7fF6/SRAWfj1o77+Hr2s7XQlLayReFYuxltPIM+MX+xXpj4Qt
 OJcSWnk9233UqfodPAyvC/Tj+I0SgElOUmkhhe5fqNtktQeJgvDO1Gs2oNBZOuMG
 +ySTT+8Dba2YbXAHYXYdyzMG1YuDZLbkvSpkYzRBH4CyfDrcTH2zkkfQSu0pAYPk
 VwdeWw05yKRNZtWhwS+eUefIXmdu8ZH2BNrYk5PobTeDhhMYx+QzoTuxyhIY+Mbq
 I1tabHrIOMy1Xyw0QsbB2/ujrt5SzNv6SLxgKaPvgPSr1uPz3Ogl3+SRziNY3zvN
 SmxSedAL5qx/TBTL+rKSKCO66aU8jAdGzvnRfwWcCoQhE+EZF5r0vSn5zIhR2Fxh
 fKKph8ZZv7426jPBuXTOurQVRs8daa+DmwHauebq4MNnhftJM1PfTb8SFOwrDTMD
 Es4M5BXgn/1RKfqjh0gKTYkbRBCtUhnHUAPmzAKFCbEENc0eC439P3wQ8lP0EzFT
 QHpdpPxeMor24HjVldfi0K4hXqNPGEnTlZwq7Asu6NAp0HcgdqIGXiLqQP3/s5ds
 gMUqOLNRAywupdpMT7db7JadnVmDRK1sHZnhk4wTAPt4Q6gqcE8=
 =qicd
 -----END PGP SIGNATURE-----

Merge tag 'for-v5.2' 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 over-current health state
   - Add standard, adaptive and custom charge types
   - Add new properties for start/end charge threshold

  New Drivers / Hardware:
   - UCS1002 Programmable USB Port Power Controller
   - Ingenic JZ47xx Battery Fuel Gauge
   - AXP20x USB Power: Add AXP813 support
   - AT91 poweroff: Add SAM9X60 support
   - OLPC battery: Add XO-1.5 and XO-1.75 support

  Misc Changes:
   - syscon-reboot: support mask property
   - AXP288 fuel gauge: Blacklist ACEPC T8/T11. Looks like some vendor
     thought it's a good idea to build a desktop system with a fuel
     gauge, that slowly "discharges"...
   - cpcap-battery: Fix calculation errors
   - misc fixes"

* tag 'for-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (54 commits)
  power: supply: olpc_battery: force the le/be casts
  power: supply: ucs1002: Fix build error without CONFIG_REGULATOR
  power: supply: ucs1002: Fix wrong return value checking
  power: supply: Add driver for Microchip UCS1002
  dt-bindings: power: supply: Add bindings for Microchip UCS1002
  power: supply: core: Add POWER_SUPPLY_HEALTH_OVERCURRENT constant
  power: supply: core: fix clang -Wunsequenced
  power: supply: core: Add missing documentation for CHARGE_CONTROL_* properties
  power: supply: core: Add CHARGE_CONTROL_{START_THRESHOLD,END_THRESHOLD} properties
  power: supply: core: Add Standard, Adaptive, and Custom charge types
  power: supply: axp288_fuel_gauge: Add ACEPC T8 and T11 mini PCs to the blacklist
  power: supply: bq27xxx_battery: Notify also about status changes
  power: supply: olpc_battery: Have the framework register sysfs files for us
  power: supply: olpc_battery: Add OLPC XO 1.75 support
  power: supply: olpc_battery: Avoid using platform_info
  power: supply: olpc_battery: Use devm_power_supply_register()
  power: supply: olpc_battery: Move priv data to a struct
  power: supply: olpc_battery: Use DT to get battery version
  x86/platform/olpc: Use a correct version when making up a battery node
  x86/platform/olpc: Trivial code move in DT fixup
  ...
2019-05-15 18:50:40 -07:00
Lubomir Rintel
baf5964ecf power: supply: olpc_battery: force the le/be casts
The endianness of data returned from the EC depends on the particular EC
version determined at run time. Cast from little/big endian explicitey
in the routine that flips endianness to the native one to make sparse
happy.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reported-by: kbuild test robot <lkp@intel.com>
Fixes: 76311b9a32 ("power: supply: olpc_battery: Add OLPC XO 1.75 support")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-14 23:17:56 +02:00
YueHaibing
c8f3c9fe83 power: supply: ucs1002: Fix build error without CONFIG_REGULATOR
Fix gcc build error while CONFIG_REGULATOR is not set

drivers/power/supply/ucs1002_power.o: In function `ucs1002_probe':
drivers/power/supply/ucs1002_power.c:593: undefined reference to `devm_regulator_register'
drivers/power/supply/ucs1002_power.o:(.rodata+0x3b8): undefined reference to `regulator_enable_regmap'
drivers/power/supply/ucs1002_power.o:(.rodata+0x3c0): undefined reference to `regulator_disable_regmap'
drivers/power/supply/ucs1002_power.o:(.rodata+0x3c8): undefined reference to `regulator_is_enabled_regmap'

Add Kconfig dependency to CONFIG_REGULATOR.

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 9a2688e426 ("power: supply: Add driver for Microchip UCS1002")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-10 18:20:50 +02:00
Axel Lin
09eb8b7c5a power: supply: ucs1002: Fix wrong return value checking
Fix wrong return value checking for devm_regulator_register and
devm_regmap_init_i2c. This looks like a copy-n-paste mistake.

Fixes: 9a2688e426 ("power: supply: Add driver for Microchip UCS1002")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-09 21:44:15 +02:00
Bartosz Golaszewski
e85e17da8a power: supply: max77650: Add support for battery charger
Add basic support for the battery charger for max77650 PMIC.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-05-08 12:06:52 +01:00
Andrey Smirnov
9a2688e426 power: supply: Add driver for Microchip UCS1002
Add driver for Microchip UCS1002 Programmable USB Port Power
Controller with Charger Emulation. The driver exposed a power supply
device to control/monitor various parameter of the device as well as a
regulator to allow controlling VBUS line.

Signed-off-by: Enric Balletbo Serra <enric.balletbo@collabora.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-03 22:16:08 +02:00
Andrey Smirnov
e3e83cc601 power: supply: core: Add POWER_SUPPLY_HEALTH_OVERCURRENT constant
Add POWER_SUPPLY_HEALTH_OVERCURRENT constant in order to allow
singalling overcurrent condition via power supply health information.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Cc: Enric Balletbo Serra <enric.balletbo@collabora.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-03 22:15:51 +02:00
Phong Tran
caee28498e power: supply: core: fix clang -Wunsequenced
The increment operator of  pointer in be32_to_cpu() is not explicitly.
It made the warning from clang:

drivers/power/supply/power_supply_core.c:674:36: error: multiple
unsequenced modifications to 'list' [-Werror,-Wunsequenced]
drivers/power/supply/power_supply_core.c:675:41: error: multiple
unsequenced modifications to 'list' [-Werror,-Wunsequenced]

Link: https://github.com/ClangBuiltLinux/linux/issues/460

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-02 22:10:46 +02:00
Nick Crews
813cab8f39 power: supply: core: Add CHARGE_CONTROL_{START_THRESHOLD,END_THRESHOLD} properties
Add POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD
and POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD properties, to expand
the existing CHARGE_CONTROL_* properties. I am adding them in order
to support a new Chrome OS device, but these properties should be
general enough that they can be used on other devices.

When the charge_type is "Custom", the charge controller uses the
POWER_SUPPLY_PROP_CHARGE_CONTROL_* properties as configuration for some
other algorithm. For example, in the use case that I am supporting,
this means the battery begins charging when the percentage
level drops below POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD and
charging ceases when the percentage level goes above
POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD.

v5 changes:
- Add the other missing CHARGE_CONTROL_* properties documentation in
  a separate commit
- Split up adding the charge types and adding the
  POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD and
  POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD properties into
  two different commits.
v4 changes:
- Add documentation for the new properties, and add documentation for
  the the previously missing charge_control_limit and
  charge_control_limit_max properties.

Signed-off-by: Nick Crews <ncrews@chromium.org>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-02 01:11:32 +02:00
Nick Crews
ba6cc85084 power: supply: core: Add Standard, Adaptive, and Custom charge types
Add "Standard", "Adaptive", and "Custom" modes to the charge_type
property, to expand the existing "Trickle" and "Fast" modes.
I am adding them in order to support a new Chrome OS device,
but these properties should be general enough that they can be
used on other devices.

The meaning of "Standard" is obvious, but "Adaptive" and "Custom" are
more tricky: "Adaptive" means that the charge controller uses some
custom algorithm to change the charge type automatically, with no
configuration needed. "Custom" means that the charge controller uses the
POWER_SUPPLY_PROP_CHARGE_CONTROL_* properties as configuration for some
other algorithm.

v5 changes:
- Split up adding the charge types and adding the
  POWER_SUPPLY_PROP_CHARGE_CONTROL_START_THRESHOLD and
  POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD properties into
  two different commits.
v4 changes:
- Add documentation for the new properties, and add documentation for
  the the previously missing charge_control_limit and
  charge_control_limit_max properties.

Signed-off-by: Nick Crews <ncrews@chromium.org>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-02 01:11:25 +02:00
Hans de Goede
9274c78305 power: supply: axp288_fuel_gauge: Add ACEPC T8 and T11 mini PCs to the blacklist
The ACEPC T8 and T11 Cherry Trail Z8350 mini PCs use an AXP288 and as PCs,
rather then portables, they does not have a battery. Still for some
reason the AXP288 not only thinks there is a battery, it actually
thinks it is discharging while the PC is running, slowly going to
0% full, causing userspace to shutdown the system due to the battery
being critically low after a while.

This commit adds the ACEPC T8 and T11 to the axp288 fuel-gauge driver
blacklist, so that we stop reporting bogus battery readings on this device.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1690852
Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-02 00:47:09 +02:00
Krzysztof Kozlowski
243f8ffc88 power: supply: bq27xxx_battery: Notify also about status changes
User-space might be interested in receiving uevents when the charging
starts/stops or if conditions of battery changes (e.g.
over-temperature).  Notify about changes in battery also when the flags
change, not only SoC.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-05-02 00:27:29 +02:00
Linus Torvalds
600d725831 Power Supply Fixes for 5.1 cycle
* cpcap-battery: fix a division by zero
 * core: fix systemd issue due to log messages produced by uevent
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlzKDOMACgkQ2O7X88g7
 +prUnhAAlQoIMn2x7DnjYo1ZL6lj4+PHSzIC9qSVA3EGdRMq49pEHYcVuVN6kwCf
 amWMjq9Yt1787jSQM/QlvnA0XjKCPSQE7qFzLa6/VrHbNh4KXaZt5I6s9k0+/qKr
 SN30EeDfrtp9AYMu/AAZe+HtdSUCo29HuZsznb3QCCszGUG30PESuqHMqV9iCmul
 c4XIBMIsl0vxDxo2jJUzLtNdSlf9bmAQIiQ68GrkGCcPmP7bRg7U4i8UImB6D34v
 LTULG5U8coCbwZb+2n6Fc6Zek1GkWYteJODSomyxHpSt/6Y4z4s4XGcrkk4sYz8R
 QVUL/I5DXnZP9CZg/tJUuyno9PFK5AgS1695SGBNODQgEFcD11QViWlYZDt4/RZh
 QRiD2L5pSB39N+WSRcAmHns7JHLmrlc2kGChvF8ULNwLMuiziVrgv9uDfNHoebRG
 v2EGj2RInXlf06tME5cA1hQzcT2CrejkpHrSp84Hina1VUMig4VDi57QURSsnyyR
 e13jwF9k7Tnbn26YNAeGtzSjDHU8CjfQ9zlHOjnyr3F+eYlJrov+4hJWSBWHPJTj
 G55BIrVkOLAd4VhbhoGwGu9hLZC2hHVV4M25Ijp7zBSNGHxcb1t5ZcUx2PAwB7R4
 RZxqosnu+B6OQjHWy8vgIBaUUbMGM1/Ldrx/uFWGVtL+qBUJIiY=
 =Q783
 -----END PGP SIGNATURE-----

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

Pull power supply fixes from Sebastian Reichel:
 "Two more fixes for the 5.1 cycle.

  One division by zero fix in a specific driver and one core workaround
  for bad userspace behaviour from systemd regarding uevents. IMHO this
  can be considered to be a userspace bug, but the debug messages are
  useless anyways

   - cpcap-battery: fix a division by zero

   - core: fix systemd issue due to log messages produced by uevent"

* tag 'for-v5.1-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  power: supply: sysfs: prevent endless uevent loop with CONFIG_POWER_SUPPLY_DEBUG
  power: supply: cpcap-battery: Fix division by zero
2019-05-01 14:57:23 -07:00
Andrey Smirnov
349ced9984 power: supply: sysfs: prevent endless uevent loop with CONFIG_POWER_SUPPLY_DEBUG
Fix a similar endless event loop as was done in commit
8dcf32175b ("i2c: prevent endless uevent loop with
CONFIG_I2C_DEBUG_CORE"):

  The culprit is the dev_dbg printk in the i2c uevent handler. If
  this is activated (for instance by CONFIG_I2C_DEBUG_CORE) it results
  in an endless loop with systemd-journald.

  This happens if user-space scans the system log and reads the uevent
  file to get information about a newly created device, which seems
  fair use to me. Unfortunately reading the "uevent" file uses the
  same function that runs for creating the uevent for a new device,
  generating the next syslog entry

Both CONFIG_I2C_DEBUG_CORE and CONFIG_POWER_SUPPLY_DEBUG were reported
in https://bugs.freedesktop.org/show_bug.cgi?id=76886 but only former
seems to have been fixed. Drop debug prints as it was done in I2C
subsystem to resolve the issue.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-26 00:06:56 +02:00
Sebastian Reichel
231a13d93d Immutable branch between x86 and power-supply for OLPC
This immutable branch contains the changes required for OLPC
 1.75 battery, which touches x86 and power-supply and is based
 on v5.1-rc1.
 
 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAly42C4ACgkQ2O7X88g7
 +ppBJhAAjQjWSbsye0WZePVfoAEuEYqJkH4E2fQpNqjrU7JEud3H5SsRVqrdfnqo
 aN/l+dm9r823bOpETYyYPBYocvcXyjSDGQnfp3TTzqK3hlU1YixiOLF1IzADS+u8
 relQuMHy8Qbr8Ms5EvDpfCHQ1BYQY9QFmEMZOFI7BXBYHvPoBYEYUoDuS7rJYSEd
 PJZ7tlkPVlqyZc2AkrXpBXJeiDU8ufKTOkwFKMsk9HI8wSdHP8czE/WGI36FULCp
 2Gx6aVC7Utt23vKzgZvAjGQF8M+OQbox5tb71iOB1LWykLNJDl94DW+yRqjangt+
 kwcAf88kKtxkI3JD2eP9xnaryevN+0ivcU4EP3TsJdW5/CO1DtbUaRPlsnq3sqQ1
 Tz020h9NCe7f7SMu6NbJFHCLjmNYxJ2GAwWYMMp9glFfziPvVSc8yW536dT6vA/p
 2KREecFoLSRx3mnzu1rPaSA2Rh0hCJiBpxTJ2qWxlxoNXwsy52QIkkJABU5f4QyG
 FqkUMgXFVk8SV4QHjrbxW56844UtWYpDLNDYcanHP25Md5RWgmocVUHH/rRWzvsh
 6TiQL83PqWUYt6yip08SoCJ6IxZi4itIvnVzJxcDysN1ByhBg3WvoD2ZnuVIPCa8
 7mxe4/ZwZxNkRqjO6QCmSIg7EAxX0ZHMeK021U09kIZNdzowVwY=
 =wNRw
 -----END PGP SIGNATURE-----

Merge tag 'psy-olpc-1.75-battery-signed' into psy-next

This immutable branch contains the changes required for OLPC
1.75 battery, which touches x86 and power-supply and is based
on v5.1-rc1.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18 22:04:22 +02:00
Lubomir Rintel
31e2208779 power: supply: olpc_battery: Have the framework register sysfs files for us
The power framework gained ability to register groups of sysfs
attributes in commit cef8fe6a38 ("power: supply: core: add support for
custom sysfs attributes").

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Suggested-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18 21:55:04 +02:00
Lubomir Rintel
76311b9a32 power: supply: olpc_battery: Add OLPC XO 1.75 support
The battery and the protocol are essentially the same as OLPC XO 1.5,
but the responses from the EC are LSB first.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18 21:54:33 +02:00
Lubomir Rintel
8ecefda222 power: supply: olpc_battery: Avoid using platform_info
This wouldn't work on the DT-based ARM platform. Let's read the EC version
directly from the EC driver instead.

This removes x86 specific bits that would prevent this driver from being
used with the EC of ARM-based OLPC XO 1.75.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18 21:53:44 +02:00
Lubomir Rintel
b0280d0580 power: supply: olpc_battery: Use devm_power_supply_register()
This simplifies the error handling.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18 21:53:21 +02:00
Lubomir Rintel
33554d818a power: supply: olpc_battery: Move priv data to a struct
The global variables for private data are not too nice. I'd like some
more, and that would clutter the global name space even further.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18 21:52:57 +02:00
Lubomir Rintel
f7a228eaf4 power: supply: olpc_battery: Use DT to get battery version
Avoid using the x86 OLPC platform specific call to get the board
version. That wouldn't work on FDT-based ARM MMP2 platform.

Add the XO 1.5 compatible string too. This is actually not completely
necessary as the battery nodes on XO 1.5 claim to be compatible with
"olpc,xo1-battery", but there are, in fact, differencies.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18 21:52:31 +02:00
Artur Rojek
fb24ccfbe1 power: supply: add Ingenic JZ47xx battery driver.
Add a driver for battery present on Ingenic JZ47xx SoCs.

Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-18 21:35:49 +02:00
Quentin Schulz
c279adafe6 power: supply: axp20x_usb_power: add support for AXP813
This adds support for AXP813 PMIC. It is almost the same as AXP22X but
has a different current limit.

Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17 23:23:15 +02:00
Quentin Schulz
af7e8d0769 power: supply: axp20x_usb_power: add function to get max current
To prepare for a new PMIC, factor out the code responsible of returning
the maximum current to axp20x_get_current_max.

Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17 23:23:15 +02:00
Chen-Yu Tsai
97ec136e71 power: supply: axp20x_usb_power: use polling to detect vbus status change
On AXP221 and later AXP PMICs that have the N_VBUSEN pin, when this pin
is high, either due to the PMIC driving it high or as an input, the VBUS
detection related interrupt mechanisms are disabled.

Previously this was worked around in the phy-sun4i-usb driver, which
needed to sense VBUS changes and report them to the musb driver in a
timely matter. However this workaround was only for the A31 and A33 type
USB PHYs. To support newer platforms we would have to enable it for
almost all the post-A31 SoCs.

However, since this is actually the result of the PMIC's behavior, the
workaround would be better if done in the PMIC driver, in this case the
VBUS power supply driver.

Add the same workqueue-based polling to the VBUS power supply driver.
The polling interval is chosen to be the debounce interval from the USB
PHY driver, as this short interval is needed in some cases, but the
power supply driver would not know when.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17 23:23:15 +02:00
Chen-Yu Tsai
c11f0b8f22 power: supply: axp20x_usb_power: Fix typo in VBUS current limit macros
The VBUS current limit value macros have VBUS typed as VBUC, while
the bitmask macro is named correctly. Fix it.

Fixes: 69fb4dcada ("power: Add an axp20x-usb-power driver")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17 23:23:15 +02:00
Wen Yang
2143bf6d7c power: supply: core: fix leaked of_node refs in power_supply_get_battery_info
The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./drivers/power/supply/power_supply_core.c:601:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function.
./drivers/power/supply/power_supply_core.c:604:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function.
./drivers/power/supply/power_supply_core.c:632:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function.
./drivers/power/supply/power_supply_core.c:635:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function.
./drivers/power/supply/power_supply_core.c:653:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function.
./drivers/power/supply/power_supply_core.c:664:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function.
./drivers/power/supply/power_supply_core.c:673:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 595, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17 22:19:12 +02:00
Wen Yang
0b646fd1b1 power: supply: ab8500: fix leaked of_node refs in ab8500_bm_of_probe
The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

492 int ab8500_bm_of_probe(struct device *dev,
493                        struct device_node *np,
494                        struct abx500_bm_data *bm)
495 {
496         const struct batres_vs_temp *tmp_batres_tbl;
497         struct device_node *battery_node;
    ...
501         /* get phandle to 'battery-info' node */
502         battery_node = of_parse_phandle(np, "battery", 0);
    ...
509         if (!btech) {
510                 dev_warn(dev, "missing property battery-name/type\n");
511                 return -EINVAL;    ---> leaked here
512         }
    ...
540         of_node_put(battery_node);   ---> released here
541
542         return 0;
543 }

Detected by coccinelle with the following warnings:
./drivers/power/supply/ab8500_bmdata.c:511:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 502, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-17 22:14:24 +02:00
Tony Lindgren
7d90fcc14a power: supply: cpcap-charger: Fix pointless EPROBE_DEFER warnings
With loadable modules we may get the following during init:

could not initialize VBUS or ID IIO: -517

Let's not print any pointless error messages for deferred probe.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 22:54:06 +02:00
Tony Lindgren
ffaf6f6773 power: supply: cpcap-battery: Fix pointless EPROBE_DEFER warnings
With loadable modules we may get the following during init:

could not initialize VBUS or ID IIO: -517

Let's not print any pointless error messages for deferred probe.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 22:53:50 +02:00
Tony Lindgren
5fc27a5419 power: supply: cpcap-battery: Use accumulator for current and power average
We should not use measured current value for average since we have proper
coulomb counter values available. Using measured current value should
be only used when the value is queried at a higher rate than the 250 ms
rate the coulomb counter is configured to run at.

Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 22:53:16 +02:00
Tony Lindgren
35439b7ab2 power: supply: cpcap-battery: Fix coulomb counter calibration register use
The coulomb counter calibration is not CCO, it's CCM. And the CCM is
nine bits wide signed register, so let's use sign_extend32() for it.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 22:52:52 +02:00
Tony Lindgren
c68b901ac4 power: supply: cpcap-battery: Fix signed counter sample register
The accumulator sample register is signed 32-bits wide register on
droid 4. And only the earlier version of cpcap has a signed 24-bits
wide register. We're currently passing it around as unsigned, so
let's fix that and use sign_extend32() for the earlier revision.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 22:52:14 +02:00
Tony Lindgren
1a9aadc86a power: supply: cpcap-battery: Fix low battery check
We need to check current instead of the charge counter to see if
a charger is connected. The charge counter shows the cumulated value
instead of the current charge current and can be negative or positive.

Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 22:51:44 +02:00
Sebastian Reichel
6f76aa94e1 Merge branch 'psy-fixes' into psy-next
Merge fixes branch into next branch for cpcap-battery
patches.

Signed-off-by: Sebastian Reichel <sre@collabora.com>
2019-04-15 22:40:29 +02:00
Artur Rojek
df68c44c72 power: supply: gpio-charger: Add support for charger status.
Introduce optional support of POWER_SUPPLY_PROP_STATUS for chargers
which provide charging status GPIO.

Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 22:07:18 +02:00
Enric Balletbo i Serra
5ec87ecde2 power: supply: core: fix typo in function to get current charge control limit
There is a spelling mistake in ps_get_cur_charge_cntl_limit function so
replace 'chrage' for 'charge'.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-15 21:40:00 +02:00
Thomas Gleixner
2aae471d66 drivers: power: supply: goldfish_battery: Fix bogus SPDX identifier
spdxcheck.py complains:

 drivers/power/supply/goldfish_battery.c: 1:28 Invalid License ID: GPL

which is correct because GPL is not a valid identifier. Of course this
could have been caught by checkpatch.pl _before_ submitting or merging the
patch.

 WARNING: 'SPDX-License-Identifier: GPL' is not supported in LICENSES/...
 #19: FILE: drivers/power/supply/goldfish_battery.c:1:
 +// SPDX-License-Identifier: GPL

Which is absolutely hillarious as the commit introducing this wreckage says
in the changelog:

  There was a checkpatch complain:

    "Missing or malformed SPDX-License-Identifier tag".

Oh well. Replacing a checkpatch warning by a different checkpatch warning
is a really useful exercise.

Use the proper GPL-2.0 identifier which is what the boiler plate in the
file had originally.

Fixes: e75e3a125b ("drivers: power: supply: goldfish_battery: Put an SPDX tag")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-15 11:16:31 +02:00
Tony Lindgren
dbe7208c6c power: supply: cpcap-battery: Fix division by zero
If called fast enough so samples do not increment, we can get
division by zero in kernel:

__div0
cpcap_battery_cc_raw_div
cpcap_battery_get_property
power_supply_get_property.part.1
power_supply_get_property
power_supply_show_property
power_supply_uevent

Fixes: 874b2adbed ("power: supply: cpcap-battery: Add a battery driver")
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-10 00:53:20 +02:00
Michael Hennerich
d7830ce3c5 power: supply: ltc3651-charger: Fix device name (rename files)
rename only - no functional changes

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-10 00:39:01 +02:00
Michael Hennerich
2e220e6eb3 power: supply: ltc3651-charger: Fix device name
There never was a device called LTC3651, it always was just LT3651.
This circumstance makes it pretty difficult to identify what this
driver is meant to control.channges since

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-10 00:39:01 +02:00
Sven Van Asbroeck
252fbeb86c power: supply: max14656: fix potential use-after-free
Explicitly cancel/sync the irq_work delayed work, otherwise
there's a chance that it will run after the device is removed,
which would result in a use-after-free.

Note that cancel/sync should happen:
- after irq's have been disabled, as the isr re-schedules the work
- before the power supply is unregistered, because the work func
    uses the power supply handle.

Cc: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 18:01:38 +02:00
Sven Van Asbroeck
0cd0e49711 power: supply: max14656: fix potential use-before-alloc
Call order on probe():
- max14656_hw_init() enables interrupts on the chip
- devm_request_irq() starts processing interrupts, isr
  could be called immediately
-    isr: schedules delayed work (irq_work)
-    irq_work: calls power_supply_changed()
- devm_power_supply_register() registers the power supply

Depending on timing, it's possible that power_supply_changed()
is called on an unregistered power supply structure.

Fix by registering the power supply before requesting the irq.

Cc: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 18:01:38 +02:00
Claudiu Beznea
17d2e876b4 power: reset: at91-poweroff: add support for SAM9X60
Add support for SAM9X60 shutdown controller.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 17:50:55 +02:00
Claudiu Beznea
5c6c513ddb power: reset: at91-poweroff: add RTT wakeup capability
Add RTT wakeup capability.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 17:50:45 +02:00
Gustavo A. R. Silva
c3422ad5f8 power: supply: axp288_charger: Fix unchecked return value
Currently there is no check on platform_get_irq() return value
in case it fails, hence never actually reporting any errors and
causing unexpected behavior when using such value as argument
for function regmap_irq_get_virq().

Fix this by adding a proper check, a message reporting any errors
and returning *pirq*

Addresses-Coverity-ID: 1443940 ("Improper use of negative value")
Fixes: 843735b788 ("power: axp288_charger: axp288 charger driver")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 16:03:44 +02:00
Maxime Ripard
f0459fe147 power: supply: Fix the simple battery property names
Commit c08b1f45d7 ("power: supply: core: Add power_supply_battery_info
and API") introduced code to parse the simple-battery node and express
battery charging constraints. However, it parsed that node using the
properties constant_charge_current_max_microamp and
constant_charge_voltage_max_microvolt, while the device tree binding for
the simple-battery node uses dashes to separate the words in those
properties (constant-charge-current-max-microamp and
constant-charge-voltage-max-microvolt).

Let's make the code match the binding.

Fixes: c08b1f45d7 ("power: supply: core: Add power_supply_battery_info and API")
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 16:00:54 +02:00
Kangjie Lu
75cf4f5aa9 power: charger-manager: fix a potential NULL pointer dereference
In case create_freezable_workqueue fails, the fix return -ENOMEM
to avoid a potential NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 16:00:06 +02:00
Martin Schiller
077d9951f7 power: reset: syscon-reboot: add a mask property
Make the syscon-reboot driver accept value and mask instead of
just value.

Prior to this patch, the property name for the value was 'mask'. If
only the mask property is defined on a node, maintain compatibility
by using it as the value.

This patch is based on commit
f2c199db47 ("power: reset: syscon-poweroff: add a mask property")
and does the same change for the syscon-reboot driver.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-04-05 15:06:57 +02:00
Nicolas Ferre
655ab0bc46 power: reset: at91-reset: add support for sam9x60 SoC
Add support for additional reset causes and the proper compatibility
string for sam9x60 SoC. The restart function is the same as the samx7.

Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-20 00:41:01 +01:00
Sven Van Asbroeck
bf592c56b1 max17042_battery: fix potential use-after-free on device remove
The work which is scheduled on a POR boot is potentially left
pending or running until after the device module is removed,
which could result in a use-after-free.

Fix by registering a cancel/sync callback, which gets executed as
part of standard resource unwinding.

This issue was detected with the help of Coccinelle.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-20 00:36:52 +01:00
Artur Rojek
04fb53101e power: supply: core: Add a field to support battery max voltage
Add a field for "voltage_max_design_uv" to present fully charged
battery voltage.

Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-20 00:33:08 +01:00
Arthur Demchenkov
9b2c945f9f bq27x00: use cached flags
The flags were just read by bq27xxx_battery_update(),
no need to read them again.

Signed-off-by: Arthur Demchenkov <spinal.by@gmail.com>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-20 00:26:38 +01:00
Sven Van Asbroeck
74f0aaba7c power: supply: ds2782: fix possible use-after-free on remove
In remove(), use cancel_delayed_work_sync() to cancel the
delayed work. Otherwise there's a chance that this work
will continue to run until after the device has been removed.

While we're here, fix the deallocation order in remove(),
to correspond to the inverse of the probe() allocation
order. This guarantees that any remaining work can run
to completion with all driver structures still intact.

This issue was detected with the help of Coccinelle.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-12 23:27:16 +01: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
Yuanjiang Yu
d3e67c94e8 power: supply: sc27xx: Fix capacity saving function
We found sometimes we can not get the saving capacity to initialize the
battery capacity, the reason is the user area registers are put on power
always-on region, so we need delay some time to wait until values are
updated successfully.

Moreover we also should clear the USER_AREA_CLEAR register after setting
the USER_AREA_SET register, otherwise we can not save the values in the
USER_AREA_SET register.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-23 21:26:56 +01:00
Baolin Wang
3a28f203c5 power: supply: sc27xx: Fix the incorrect formula when converting capacity to coulomb counter
We should multiply the calibrated current data (cur_1000ma_adc) when
converting current capacity (mAh) to coulomb counter, which can get
an accurate coulomb counter from the fuel gauge controller.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-23 21:26:56 +01:00
Baolin Wang
0a4f97a171 power: supply: sc27xx: Add one property to read charge voltage
Add POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE property to get charge
voltage sampling by ADC controller, which is used to validate if the
charge voltage is in normal range or not in charger manager.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-23 21:26:56 +01:00
Roman Kiryanov
2a7b0a29b3 drivers: power: supply: goldfish_battery: Add support for reading more properties
To comply with tests we need to support more power supply properties:

POWER_SUPPLY_PROP_VOLTAGE_NOW
POWER_SUPPLY_PROP_TEMP
POWER_SUPPLY_PROP_CHARGE_COUNTER
POWER_SUPPLY_PROP_CURRENT_NOW
POWER_SUPPLY_PROP_CURRENT_AVG
POWER_SUPPLY_PROP_CHARGE_FULL
POWER_SUPPLY_PROP_CYCLE_COUNT
POWER_SUPPLY_PROP_VOLTAGE_MAX
POWER_SUPPLY_PROP_CURRENT_MAX

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-21 22:31:27 +01:00
Krzysztof Kozlowski
02276af2fc power: supply: charger-manager: Fix trivial language typos
Fix few trivial language typos.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:45:08 +01:00
Pavel Machek
fd10606f93 cpcap-charger: generate events for userspace
The driver doesn't generate uevents on charger connect/disconnect.
This leads to UPower not detecting when AC is on or off... and that is
bad.

Reported by Arthur D. on github (
https://github.com/maemo-leste/bugtracker/issues/206 ), thanks to
Merlijn Wajer for suggesting a fix.

Cc: stable@kernel.org
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:40:27 +01:00
Yangtao Li
19836a1b8e power: supply: remove some duplicated includes
We include of.h twice. It's unnecessary,so
just remove them.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:39:23 +01:00
Kangjie Lu
6f12e46eeb power: twl4030: fix a missing check of return value
If twl4030_bci_read() fails, the read data in "s" is incorrect,
which is however used in the following execution. The fix checks
the return value of twl4030_bci_read() and returns an error code
upstream upon the failure of twl4030_bci_read().

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:38:35 +01:00
Roman Kiryanov
3dcdb68925 drivers: power: supply: goldfish_battery: Use tabs for alignment
Tabs are preferred.

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:29:54 +01:00
Roman Kiryanov
617ee863ed drivers: power: supply: goldfish_battery: Fix alignment
Align two values as other values below.

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:29:36 +01:00
Roman Kiryanov
5fbde356cb drivers: power: supply: goldfish_battery: Retire a redundant variable
The battery_data static variable was not used.

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:29:22 +01:00
Roman Kiryanov
65ab18a1aa drivers: power: supply: goldfish_battery: Fix "line over 80 characters"
There was a line longer than 80 characters.

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:28:54 +01:00
Roman Kiryanov
e75e3a125b drivers: power: supply: goldfish_battery: Put an SPDX tag
There was a checkpatch complain:

"Missing or malformed SPDX-License-Identifier tag".

Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:28:10 +01:00
Yangtao Li
0367e23425 power: supply: axp288_fuel_gauge: Change to use DEFINE_SHOW_ATTRIBUTE macro
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 22:21:45 +01:00
Sebastian Reichel
f5d782d46a power: supply: isp1704: switch to gpiod API
This migrates isp1704 driver from old GPIO API to new descriptor
based GPIO API and drops useless platform data as a side-effect.

Migration is simple, since all mainline users are DT based and
DT API does not change. Out of tree users of the platform data
need to migrate to gpiod_lookup_table as described here:

Documentation/driver-api/gpio/board.rst

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-01-20 21:57:43 +01:00
Linus Torvalds
579a700359 power supply and reset changes for the v4.21 series
* New core support
  - battery internal resistance
  - battery OCV capacity lookup table
  - support for custom sysfs attributes
 * Convert all drivers to use power-supply core support for custom sysfs attributes
 * bq24190-charger: bq24196 support
 * axp20x-charger: AXP813 support
 * sc27xx-battery: new fuel gauge driver
 * gpio-poweroff: support for specific active and inactive delays
 * Misc fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlwlThQACgkQ2O7X88g7
 +pqmHg/+PPPeJVIfAAdxFe4KPvP/sAUnAGxqgJc7yeaKOq03eIWnm0JFbEsQLazM
 XDyk+8N7PQ254n2hU/DQln/OKrkVMo/QaOsn3HbbxaDbUiM5Mj8WjKOzgjWtgUy0
 OZOEk6n4SQNx6Ib7Wp/e+H6b/K+EglO5CVZDXmTBJfFKiKp5g4A3ZaUe8bCa1xuG
 4AB3QWQPomtI8o/nD37c4lpegojabUGN8hHI6r9TFT1PaYEzAmOQsb0NnGqEKAUw
 ECPBeH4jVoLN9Bie4u5Fgdr0lqukG+EAEHlHhPRea92oDLFfXEjPOI9JDM4XWBg/
 P47KNuvsVrIAUQ3rnCHUP4aC2ElL0G9bcEyADiLOuw9FIjMMjBm65pyRDORwkH+L
 TAu/28fL2Rzwenk+N8OLZ5lpvYlrqpDFISJkwO7gSGq4wyNW8I62GXJPFAYuSZsf
 dvlEOTgUCwNUnnF2ehx1AkvOBE+eh1CHvtcbKUMLwtBgWOhVi664Gm2znaLy6PwN
 XPkcRCNFIr/FZRuAo1x9GyxYv483Nk+27LcKfwz+HtmHHMRRDHDWtJ/K0KqK/y7a
 7HE7tBhCMpWikIXT1pAz7A0XYlMqfaMsyHlOqmeFgsNUBuDvJAArDz3Gff935PL3
 KGIr4lp+YeTHv6nJT/EMtGIG2dsJZUHh/NAtWZ07usI2fOgE3J4=
 =59iw
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - New core support:
    - battery internal resistance
    - battery OCV capacity lookup table
    - support for custom sysfs attributes

 - Convert all drivers to use power-supply core support for custom sysfs
   attributes

 - bq24190-charger: bq24196 support

 - axp20x-charger: AXP813 support

 - sc27xx-battery: new fuel gauge driver

 - gpio-poweroff: support for specific active and inactive delays

 - Misc fixes

* tag 'for-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (53 commits)
  power: supply: bq25890: fix BAT_COMP field definition
  power: supply: gpio-charger: Do not use deprecated POWER_SUPPLY_TYPE_USB_*
  power: supply: ds2781: switch to devm_power_supply_register
  power: supply: ds2780: switch to devm_power_supply_register
  power: supply: ds2781: fix race-condition in bin attribute registration
  power: supply: ds2780: fix race-condition in bin attribute registration
  power: supply: pcf50633: fix race-condition in sysfs registration
  power: supply: charger-manager: fix race-condition in sysfs registration
  power: supply: charger-manager: simplify generation of sysfs attribute group name
  power: supply: bq24257: fix race-condition in sysfs registration
  power: supply: bq24190_charger: fix race-condition in sysfs registration
  power: supply: lp8788: fix race-condition in sysfs registration
  power: supply: ds2781: fix race-condition in sysfs registration
  power: supply: ds2780: fix race-condition in sysfs registration
  power: supply: bq2415x: fix race-condition in sysfs registration
  power: supply: core: add support for custom sysfs attributes
  power: supply: sc27xx: Save last battery capacity
  power: reset: at91-poweroff: move shdwc related data to one structure
  power: supply: sc27xx: Add suspend/resume interfaces
  power: supply: sc27xx: Add fuel gauge low voltage alarm
  ...
2018-12-28 20:22:45 -08:00
Linus Torvalds
030672aea8 Merge tag 'devicetree-for-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
Pull Devicetree updates from Rob Herring:
 "The biggest highlight here is the start of using json-schema for DT
  bindings. Being able to validate bindings has been discussed for years
  with little progress.

   - Initial support for DT bindings using json-schema language. This is
     the start of converting DT bindings from free-form text to a
     structured format.

   - Reworking of initrd address initialization. This moves to using the
     phys address instead of virt addr in the DT parsing code. This
     rework was motivated by CONFIG_DEV_BLK_INITRD causing unnecessary
     rebuilding of lots of files.

   - Fix stale phandle entries in phandle cache

   - DT overlay validation improvements. This exposed several memory
     leak bugs which have been fixed.

   - Use node name and device_type helper functions in DT code

   - Last remaining conversions to using %pOFn printk specifier instead
     of device_node.name directly

   - Create new common RTC binding doc and move all trivial RTC devices
     out of trivial-devices.txt.

   - New bindings for Freescale MAG3110 magnetometer, Cadence Sierra
     PHY, and Xen shared memory

   - Update dtc to upstream version v1.4.7-57-gf267e674d145"

* tag 'devicetree-for-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (68 commits)
  of: __of_detach_node() - remove node from phandle cache
  of: of_node_get()/of_node_put() nodes held in phandle cache
  gpio-omap.txt: add reg and interrupts properties
  dt-bindings: mrvl,intc: fix a trivial typo
  dt-bindings: iio: magnetometer: add dt-bindings for freescale mag3110
  dt-bindings: Convert trivial-devices.txt to json-schema
  dt-bindings: arm: mrvl: amend Browstone compatible string
  dt-bindings: arm: Convert Tegra board/soc bindings to json-schema
  dt-bindings: arm: Convert ZTE board/soc bindings to json-schema
  dt-bindings: arm: Add missing Xilinx boards
  dt-bindings: arm: Convert Xilinx board/soc bindings to json-schema
  dt-bindings: arm: Convert VIA board/soc bindings to json-schema
  dt-bindings: arm: Convert ST STi board/soc bindings to json-schema
  dt-bindings: arm: Convert SPEAr board/soc bindings to json-schema
  dt-bindings: arm: Convert CSR SiRF board/soc bindings to json-schema
  dt-bindings: arm: Convert QCom board/soc bindings to json-schema
  dt-bindings: arm: Convert TI nspire board/soc bindings to json-schema
  dt-bindings: arm: Convert TI davinci board/soc bindings to json-schema
  dt-bindings: arm: Convert Calxeda board/soc bindings to json-schema
  dt-bindings: arm: Convert Altera board/soc bindings to json-schema
  ...
2018-12-28 20:08:34 -08: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
Sebastian Reichel
fb4d494480 power: supply: gpio-charger: Do not use deprecated POWER_SUPPLY_TYPE_USB_*
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:17:01 +01:00
Sebastian Reichel
fbd17e58d4 power: supply: ds2781: switch to devm_power_supply_register
Simplify/Cleanup the driver by switching to devm_power_supply_register
and dropping the driver's remove function.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:56 +01:00
Sebastian Reichel
63fac6cb63 power: supply: ds2780: switch to devm_power_supply_register
Simplify/Cleanup the driver by switching to devm_power_supply_register
and dropping the driver's remove function.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:47 +01:00
Sebastian Reichel
711aebcfe3 power: supply: ds2781: fix race-condition in bin attribute registration
This is a follow-up patch to the previous one, which fixed a
race-condition during registration of the attribute group.
This fixes the same issue for the binary attributes by adding
them to the properly registered group. As a side effect the
code is further cleaned up.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:39 +01:00
Sebastian Reichel
88635b6da8 power: supply: ds2780: fix race-condition in bin attribute registration
This is a follow-up patch to the previous one, which fixed a
race-condition during registration of the attribute group.
This fixes the same issue for the binary attributes by adding
them to the properly registered group. As a side effect the
code is further cleaned up.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:31 +01:00
Sebastian Reichel
451ba0e436 power: supply: pcf50633: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:24 +01:00
Sebastian Reichel
157ba1bb5f power: supply: charger-manager: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:20 +01:00
Sebastian Reichel
efcca6bdfb power: supply: charger-manager: simplify generation of sysfs attribute group name
This is a simple cleanup and there should be no functional changes.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:16 +01:00
Sebastian Reichel
750688c7cd power: supply: bq24257: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:12 +01:00
Sebastian Reichel
348a3c079b power: supply: bq24190_charger: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:08 +01:00
Sebastian Reichel
b1f7ee898b power: supply: lp8788: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:16:02 +01:00
Sebastian Reichel
a45cefb0ca power: supply: ds2781: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:15:47 +01:00
Sebastian Reichel
b10474aafe power: supply: ds2780: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:15:42 +01:00
Sebastian Reichel
06215ce999 power: supply: bq2415x: fix race-condition in sysfs registration
This registers custom sysfs properties using the native functionality
of the power-supply framework, which cleans up the code a bit and
fixes a race-condition. Before this patch the sysfs attributes were
not properly registered to udev.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:15:21 +01:00
Sebastian Reichel
cef8fe6a38 power: supply: core: add support for custom sysfs attributes
Add functionality to setup device specific sysfs attributes
in a race condition free manner

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-13 00:15:06 +01:00
Nishanth Menon
f9dca0f067 PM / AVS: SmartReflex: Switch to SPDX Licence ID
Fix up licensing to be inline with Linux conventions.

Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-12-12 13:54:28 +01:00
Thomas Meyer
14d338a857 PM / AVS: SmartReflex: NULL check before some freeing functions is not needed
NULL check before some freeing functions is not needed.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-12-12 13:54:05 +01:00
Rafael J. Wysocki
c76aa32207 Merge back staging AVS changes for v4.21. 2018-12-11 12:02:46 +01:00
Yuanjiang Yu
4a040e7c72 power: supply: sc27xx: Save last battery capacity
Our charger manager can optimize the battery capacity periodically, so
we can save last battery capacity into registers. Then next system
power-on, we can read the last saved battery capacity as the initial
battery capacity, which can make the battery capacity more accurate.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-06 22:24:39 +01:00
Claudiu Beznea
caa6e150f8 power: reset: at91-poweroff: move shdwc related data to one structure
Move SHDWC realted data to only one structure to have them grouped.
Inspired from commit 9be74f0d39 ("power: reset: at91-poweroff: make
mpddrc_base part of struct shdwc").

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-06 21:56:37 +01:00
Yuanjiang Yu
e2fb615b69 power: supply: sc27xx: Add suspend/resume interfaces
Add fuel gauge platform suspend and resume interfaces. In suspend state,
we should enable the low voltage and coulomb counter threshold interrupts
to wake up system to calibrate the battery capacity in lower voltage stage.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-06 01:04:30 +01:00
Yuanjiang Yu
edcb1c0a3f power: supply: sc27xx: Add fuel gauge low voltage alarm
Add low voltage alarm support to make sure the battery capacity
more accurate in lower voltage stage.

Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-06 01:04:30 +01:00
Baolin Wang
65c9fab7bc power: supply: sc27xx: Add fuel gauge calibration
This patch adds support to read calibration values from the eFuse controller
to calibrate the ADC values corresponding to current and voltage, which can
make the current and voltage data more accurate.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-06 00:54:22 +01:00
Baolin Wang
872bcf83ec power: supply: sc2731_charger: Free battery information
Free battery information in case of adding battery OCV tables.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:54:01 +01:00
Baolin Wang
a8aaff6be0 power: supply: sc2731_charger: Avoid repeated charge/discharge
Add info->charging validation to avoid repeated charge or discharge
operation.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:53:14 +01:00
Baolin Wang
18c807dbf9 power: supply: sc2731_charger: Add charger status detection
The USB charger status can be notified before the charger driver registers
the USB phy notifier, so we should check the charger status in probe() in
case we missed the USB charger notification.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:51:58 +01:00
Baolin Wang
8ac1091ed1 power: supply: sc2731_charger: Add one work to charge/discharge
Since the USB notifier context is atomic, we can not start or stop charging
in atomic context. Thus this patch adds one work to help to charge or
discharge.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:48:17 +01:00
Claudiu.Beznea@microchip.com
e6ae9a05a4 power: reset: at91-poweroff: remove at91_ramc_of_match
Remove at91_ramc_of_match[] since it is not used anywhere in this code.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:29:57 +01:00
Claudiu.Beznea@microchip.com
996463fdb8 power: reset: at91-poweroff: use one poweroff function for at91-poweroff
Use only one poweroff function and adapt it to work for both scenarios
(with LPDDR or not). The assignement of pm_power_off was moved at the
end of probe after all initializations are OK. This patch adapt the idea
from commit 4e018c1e9b ("power: reset: at91-poweroff: use only one
poweroff function").

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 23:18:30 +01:00
Heiko Stuebner
d0717d73be power: supply: bq24190_charger: add support for bq24196 variant
The bq24196 is another variant of the bq24190 charger ic.
Its register set is identical to the bq24192 and it even reuses
the same part number (0x5).

Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:57:56 +01:00
Brian Masney
161a2135e0 power: supply: bq24190_charger: add extcon support for USB OTG
Add extcon support so that we can notify USB drivers of cable state
changes. Based on work from Jonathan Marek. USB OTG was tested on a LG
Nexus 5 (hammerhead) phone.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:53:32 +01:00
Jonathan Marek
74d09c927c power: supply: bq24190_charger: add of_match for usb-otg-vbus regulator
This patch adds an of_match for the usb-otg-vbus regulator to
bq24190_charger.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:52:05 +01:00
Jonathan Marek
5ea67bb0b0 power: supply: bq24190_charger: add support for bq24192 variant
This patch adds support for the bq24192 variant to bq24190_charger.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
[masneyb@onstation.org: Changed if statement to a switch based on
feedback from Sebastian Reichel.]
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:51:58 +01:00
Alexandre Belloni
9afe62509b power: reset: ocelot: switch the SI to boot mode
Switch the SI to boot mode so on a warm reboot, the SI is able to access
the flash.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:40:25 +01:00
Heiko Stuebner
76ee875c2f power: reset: gpio-poweroff: add ability to specific active and inactive delays
Similar to gpio-reset allow to specify active and inactive delays
while keeping the 100ms defaults that were used previously all the time.

The dt-properties are named the same as in gpio-reset but get an "-ms"
suffix as properties should contain such a suffix specifying its unit.

Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 22:38:29 +01:00
Baolin Wang
a53a68cee8 power: supply: charger-manager: Make code more readable
Make code more readable.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 21:25:44 +01:00
Baolin Wang
f25a646fbe power: supply: charger-manager: Fix incorrect return value
Fix incorrect return value.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 21:25:01 +01:00
Baolin Wang
8c13b6f18a power: supply: charger-manager: Fix some misspelled words
Fix some misspelled words.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 21:24:37 +01:00
Baolin Wang
1dd3509929 power: supply: charger-manager: Remove unused index counting
Remove unused index counting.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 21:24:21 +01:00
Colin Ian King
80fca773bf power: supply: cpcap-charger: clean an indentation issue, remove tab
Trivial fix to clean up indentation issue, remove an extraneous tab

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 19:02:11 +01:00
Sebastian Reichel
8f01c45a0f Immutable branch between mfd and power-supply for driver
changes related to axp813.
 
 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlwIEC4ACgkQ2O7X88g7
 +pr0FQ//YwW7NxbxgNsYH2z7tLUct5LgElj3HGVFO++OJGe+cEh4jDdNUqfjGhyb
 ww5NkRZuUBZSqKoGukAARAbTH/gYQloNQV2C6EEk/AULYPkIG84tBRtDv2INBHxM
 InoHLEvNZ4n4lDzmNzwjaUxxfUoRwFj1Rz1+dAYzuoC6ImFYqzwEuggwI9cRLd6h
 hCVIh7lasGLQ9aCX04agE53ki4t52PGn8klRNUhdRS5T944g/8a1pdMoHT7faCFA
 hbIMrC9LdEgUCdOkWwYGa87wfz1+DNfwTY7DC+/2P3ItGh8cV/w1Hi3IK6XRPVDY
 1Gp6RYNtmB+EX2j0lSOvf6uUFx/YKbDkyJZlZY75ZLK/hb8Rl+RDIX8WQKA1tdAY
 ie/8+DOSdnT+pQH1xGg+615fTnGWAK0W0rUaZdAmCwlBEfusBt2mtjOhuRuGXpSS
 hua3KIZqX7FIKtcnPZ6dZ6oYKABgcEkUjap74F2Vc0sUFsrHv5BTR1/tiwmrNvnA
 mD05Y9ApcEAA9TK9SAUOHRkvfS7fogBXjZqtKWB0BLHDZZQKZtItvzjx6R1tQaQs
 5Vl19AIdeIjcnHPUKj8B7KtZk5LbdlvEiarxMbEVrijjh49K6gPr1PrvGTD74zuN
 yafd7sRA2d8T1fSBkeNUTaJcEjRX7Q4IBmacVnFks/teynz6jhg=
 =FoKv
 -----END PGP SIGNATURE-----

Merge tag 'psy-mfd-axp813-immutable-for-v4.21-signed' into psy-next

Immutable branch between mfd and power-supply for driver
changes related to axp813.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 18:52:09 +01:00
Oskari Lemmela
7693b5643f power: supply: add AC power supply driver for AXP813
AXP813 and AXP803 PMICs can control input current and minimum voltage.

Both of these values are configurable.

Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
Reviewed-by: Quentin Schulz <quentin.schulz@bootlin.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 18:49:32 +01:00
Olliver Schinagl
a95761d6d2 power: supply: axp288: use the BIT() macro
Make use of the recommended BIT() macro for bit defines.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 18:39:56 +01:00
Olliver Schinagl
57428f6f8a power: supply: axp20x: add missing include bitops.h
The axp20x_usb_power driver uses BIT() operations but lacks the include
for it. Include the bitops.h header file.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 18:39:00 +01:00
Colin Ian King
bd82ef0838 power: supply: cpcap-battery: make array cpcap_battery_irqs static, shrinks object size
Don't populate the array cpcap_battery_irqs  on the stack but instead
make it static. Makes the object code smaller by 99 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  13673	   2448	      0	  16121	   3ef9	cpcap-battery.o

After:
   text	   data	    bss	    dec	    hex	filename
  13510	   2512	      0	  16022	   3e96	cpcap-battery.o

(gcc version 8.2.0 x86_64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-12-05 00:24:36 +01:00
Rob Herring
e31d0fc6fd power: reset: Convert to using %pOFn instead of device_node.name
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
2018-11-27 10:55:38 -06:00
Lubomir Rintel
ed54ffbe55 power: supply: olpc_battery: correct the temperature units
According to [1] and [2], the temperature values are in tenths of degree
Celsius. Exposing the Celsius value makes the battery appear on fire:

  $ upower -i /org/freedesktop/UPower/devices/battery_olpc_battery
  ...
      temperature:         236.9 degrees C

Tested on OLPC XO-1 and OLPC XO-1.75 laptops.

[1] include/linux/power_supply.h
[2] Documentation/power/power_supply_class.txt

Fixes: fb972873a7 ("[BATTERY] One Laptop Per Child power/battery driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-11-19 14:14:46 +01:00
Randy Dunlap
ed60f43d01 power/supply: fix sc27xx_fuel_gauge build errors
Fix build errors when FUEL_GUAGE_SC27XX is enabled but IIO is either
not enabled or IIO=m and FUEL_GUAGE_SC27XX=y.

ld: drivers/power/supply/sc27xx_fuel_gauge.o: in function `sc27xx_fgu_get_temp':
sc27xx_fuel_gauge.c:(.text+0x1d2): undefined reference to `iio_read_channel_processed'
ld: drivers/power/supply/sc27xx_fuel_gauge.o: in function `sc27xx_fgu_probe':
sc27xx_fuel_gauge.c:(.text+0x97f): undefined reference to `devm_iio_channel_get'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: linux-pm@vger.kernel.org
Acked-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-11-13 03:03:21 +01:00
Baolin Wang
195ca17037 power: supply: Add Spreadtrum SC27XX fuel gauge unit driver
This patch adds the Spreadtrum SC27XX serial PMICs fuel gauge support,
which is used to calculate the battery capacity.

Original-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-11-09 22:55:46 +01:00
Baolin Wang
3afb50d712 power: supply: core: Add some helpers to use the battery OCV capacity table
We have introduced some battery properties to present the OCV table
temperatures and OCV capacity table values. Thus this patch add OCV
temperature and OCV table for battery information, as well as providing
some helper functions to use the OCV capacity table for users.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-11-09 22:55:46 +01:00
Baolin Wang
86131d933f power: supply: core: Add one field to present the battery internal resistance
Add one field for 'struct power_supply_battery_info' to present the battery
factory internal resistance.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-11-09 22:55:46 +01:00
Linus Torvalds
b27186abb3 Devicetree updates for 4.20:
- Sync dtc with upstream version v1.4.7-14-gc86da84d30e4
 
 - Work to get rid of direct accesses to struct device_node name and
   type pointers in preparation for removing them. New helpers for
   parsing DT cpu nodes and conversions to use the helpers. printk
   conversions to %pOFn for printing DT node names. Most went thru
   subystem trees, so this is the remainder.
 
 - Fixes to DT child node lookups to actually be restricted to child
   nodes instead of treewide.
 
 - Refactoring of dtb targets out of arch code. This makes the support
   more uniform and enables building all dtbs on c6x, microblaze, and
   powerpc.
 
 - Various DT binding updates for Renesas r8a7744 SoC
 
 - Vendor prefixes for Facebook, OLPC
 
 - Restructuring of some ARM binding docs moving some peripheral bindings
   out of board/SoC binding files
 
 - New "secure-chosen" binding for secure world settings on ARM
 
 - Dual licensing of 2 DT IRQ binding headers
 -----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEEktVUI4SxYhzZyEuo+vtdtY28YcMFAlvTKWYQHHJvYmhAa2Vy
 bmVsLm9yZwAKCRD6+121jbxhw8J5EACMAnrTxWQmXfQXOZEVxztcFavH6LP8mh2e
 7FZIZ38jzHXXvl81tAg1nBhzFUU/qtvqW8NDCZ9OBxKvp6PFDNhWu241ZodSB1Kw
 MZWy2A9QC+qbHYCC+SB5gOT0+Py3v7LNCBa5/TxhbFd35THJM8X0FP7gmcCGX593
 9Ml1rqawT4mK5XmCpczT0cXxyC4TgVtpfDWZH2KgJTR/kwXVQlOQOGZ8a1y/wrt7
 8TLIe7Qy4SFRzjhwbSta1PUehyYfe4uTSsXIJ84kMvNMxinLXQtvd7t9TfsK8p/R
 WjYUneJskVjtxVrMQfdV4MxyFL1YEt2mYcr0PMKIWxMCgGDAZsHPoUZmjyh/PrCI
 uiZtEHn3fXpUZAV/xEHHNirJxYyQfHGiksAT+lPrUXYYLCcZ3ZmqiTEYhGoQAfH5
 CQPMuxA6yXxp6bov6zJwZSTZtkXciju8aQRhUhlxIfHTqezmGYeql/bnWd+InNuR
 upANLZBh6D2jTWzDyobconkCCLlVkSqDoqOx725mMl6hIcdH9d2jVX7hwRf077VI
 5i3CyPSJOkSOLSdB8bAPYfBoaDtH2bthxieUrkkSbIjbwHO1H6a2lxPeG/zah0a3
 ePMGhi7J84UM4VpJEi000cP+bhPumJtJrG7zxP7ldXdfAF436sQ6KRptlcpLpj5i
 IwMhUQNH+g==
 =335v
 -----END PGP SIGNATURE-----

Merge tag 'devicetree-for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux

Pull Devicetree updates from Rob Herring:
 "A bit bigger than normal as I've been busy this cycle.

  There's a few things with dependencies and a few things subsystem
  maintainers didn't pick up, so I'm taking them thru my tree.

  The fixes from Johan didn't get into linux-next, but they've been
  waiting for some time now and they are what's left of what subsystem
  maintainers didn't pick up.

  Summary:

   - Sync dtc with upstream version v1.4.7-14-gc86da84d30e4

   - Work to get rid of direct accesses to struct device_node name and
     type pointers in preparation for removing them. New helpers for
     parsing DT cpu nodes and conversions to use the helpers. printk
     conversions to %pOFn for printing DT node names. Most went thru
     subystem trees, so this is the remainder.

   - Fixes to DT child node lookups to actually be restricted to child
     nodes instead of treewide.

   - Refactoring of dtb targets out of arch code. This makes the support
     more uniform and enables building all dtbs on c6x, microblaze, and
     powerpc.

   - Various DT binding updates for Renesas r8a7744 SoC

   - Vendor prefixes for Facebook, OLPC

   - Restructuring of some ARM binding docs moving some peripheral
     bindings out of board/SoC binding files

   - New "secure-chosen" binding for secure world settings on ARM

   - Dual licensing of 2 DT IRQ binding headers"

* tag 'devicetree-for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (78 commits)
  ARM: dt: relicense two DT binding IRQ headers
  power: supply: twl4030-charger: fix OF sibling-node lookup
  NFC: nfcmrvl_uart: fix OF child-node lookup
  net: stmmac: dwmac-sun8i: fix OF child-node lookup
  net: bcmgenet: fix OF child-node lookup
  drm/msm: fix OF child-node lookup
  drm/mediatek: fix OF sibling-node lookup
  of: Add missing exports of node name compare functions
  dt-bindings: Add OLPC vendor prefix
  dt-bindings: misc: bk4: Add device tree binding for Liebherr's BK4 SPI bus
  dt-bindings: thermal: samsung: Add SPDX license identifier
  dt-bindings: clock: samsung: Add SPDX license identifiers
  dt-bindings: timer: ostm: Add R7S9210 support
  dt-bindings: phy: rcar-gen2: Add r8a7744 support
  dt-bindings: can: rcar_can: Add r8a7744 support
  dt-bindings: timer: renesas, cmt: Document r8a7744 CMT support
  dt-bindings: watchdog: renesas-wdt: Document r8a7744 support
  dt-bindings: thermal: rcar: Add device tree support for r8a7744
  Documentation: dt: Add binding for /secure-chosen/stdout-path
  dt-bindings: arm: zte: Move sysctrl bindings to their own doc
  ...
2018-10-26 12:09:58 -07:00
Johan Hovold
9844fb2e35 power: supply: twl4030-charger: fix OF sibling-node lookup
Use the new of_get_compatible_child() helper to lookup the usb sibling
node instead of using of_find_compatible_node(), which searches the
entire tree from a given start node and thus can return an unrelated
(non-sibling) node.

This also addresses a potential use-after-free (e.g. after probe
deferral) as the tree-wide helper drops a reference to its first
argument (i.e. the parent device node).

While at it, also fix the related phy-node reference leak.

Fixes: f5e4edb8c8 ("power: twl4030_charger: find associated phy by more reliable means.")
Cc: stable <stable@vger.kernel.org>     # 4.2
Cc: NeilBrown <neilb@suse.de>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Sebastian Reichel <sre@kernel.org>
Reviewed-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
2018-10-23 13:28:53 -05:00
Gustavo A. R. Silva
cfb347979e power: max8925: mark expected switch fall-through
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 201510 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-10-21 21:33:35 +02:00
Colin Ian King
415d602b22 power: supply: fix spelling mistake "Gauage" -> "Gauge"
Trivial fix to spelling mistake in MODULE_DESCRIPTION text

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-10-21 21:32:44 +02:00
Uwe Kleine-König
2d12df47ea PM / AVS: SmartReflex: remove unused function
omap_sr_register_pmic() was introduced in 2010 in commit

	984aa6dbf4 ("OMAP3: PM: Adding smartreflex driver support.")

. There was never any caller of this function in mainline resulting in a
warning

	sr_init: No PMIC hook to init smartreflex

for each machine where this driver is enabled. So remove the unused
function and the pr_warn.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-10-09 09:50:19 +02:00
Vinod Koul
a4ac1f5ced power: reset: qcom-pon: Add pms405 pon support
Update the binding and driver for pms405 pon.

Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-20 11:40:00 +02:00
Liu Xiang
457b42f0aa power: supply: bq27xxx: Add support for BQ27411
According to the datasheet, bq27411 is similar to bq27421.

Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn>
Reviewed-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-20 11:35:40 +02:00
Baolin Wang
1c3d7b0364 power: supply: Add Spreadtrum SC2731 charger support
This patch adds the SC2731 PMIC switch charger support.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-20 02:58:08 +02:00
Andreas Kemnade
079cdff3d0 power: supply: twl4030_charger: disable eoc interrupt on linear charge
This avoids getting woken up from suspend after power interruptions
when the bci wrongly thinks the battery is full just because
of input current going low because of low input power

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-20 02:16:44 +02:00
Andreas Kemnade
8314c212f9 power: supply: twl4030_charger: fix charging current out-of-bounds
the charging current uses unsigned int variables, if we step back
if the current is still low, we would run into negative which
means setting the target to a huge value.
Better add checks here.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-20 02:15:41 +02: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
Tomasz Figa
cb90a2c6f7 power: supply: max8998-charger: Fix platform data retrieval
Since the max8998 MFD driver supports instantiation by DT, platform data
retrieval is handled in MFD probe and cell drivers should get use
the pdata field of max8998_dev struct to obtain them.

Fixes: ee999fb3f1 ("mfd: max8998: Add support for Device Tree")
Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 13:46:39 +02:00
Sebastian Reichel
782853cf9b Immutable branch for mfd and power-supply for v4.20
Immutable branch between mfd and power-supply for driver
 changes in CROS USBPD charger driver.
 
 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlueOg8ACgkQ2O7X88g7
 +powaA//eiDVCADkBlnhzzfks3KEpkoGCS4Hct3uIcKri7Nuua9KhHrkun6rUzmO
 +CTx78sQl9Ctswr78/40TaXsgc+EfbGIMBB8Prrux2P8cy+QbVWD3dRfZKyc/oQp
 m9MrJqa4jmvSLnKmujXP+bIlWVBc1OTDo+O1OVH1J1dBnGmR/LrvVBbVHnx7H5tj
 LAhNZ40GxDDNXd94uZ1csxlulSV3/ezWto8Lp8lyh4fuYLnpGBl/k/x15HoaBcQ1
 TPSMg7I8OPrQkZaJQ3d2nMmpDmyuNgO4KTA7rLXc8MlwRGl4gx9zSZVOTstMlhE/
 oVR5DSRnxIMQO7JUSRLtmYOWYQmVWRDZVs3+O9UQv2WPecsz9aCvMbkxYHeJIGkD
 9jPTd/OT7uBmV+xketpTLPuIFcS72HDrrPhZAstkj+klt/aSoQDp9lecjcgU1ArE
 wAppp0YZ2Fj+m73XzDIUe3EqUMOmIBPQfUJd60ZAHOJot9p/4v40rnwgg8VA+WmU
 JhawDNa6Wq4cYYOpFPgPXWmsXB2mgPKJV+X6tjDDpwEtn+QF5c9OFWakgX06WN9h
 gZss2Qbn75dFDJUQyRzM8F5RkjVh7NrU1dMOgBMEXN5Hqb1//YJ5q4hiL280uFkD
 n9B07QL7oSvaV3qcXTkFFDqJG44nH91J6AMxUAqDG5L9Y63l5Hg=
 =ya3t
 -----END PGP SIGNATURE-----

Merge tag 'psy-mfd-cros-immutable-for-v4.20-signed' into psy-next

Immutable branch for mfd and power-supply for v4.20

Immutable branch between mfd and power-supply for driver
changes in CROS USBPD charger driver.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 13:10:37 +02:00
Fabien Parent
3af15cfacd power: supply: cros: add support for dedicated port
ChromeOS devices can have one optional dedicated port.
The Dedicated port is unique and similar to the USB PD ports
except that it doesn't support as many properties.

The presence of a dedicated port is determined from whether the
EC's charger port count is equal to 'number of USB PD port' + 1.
The dedicated port ID is always the last valid port ID.

This commit keeps compatibility with Embedded Controllers that do not
support the new EC_CMD_CHARGE_PORT_COUNT command by setting
the number of charger port to be equal to the number of USB PD port
when this command fails.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 12:55:25 +02:00
Sebastian Reichel
2e04dd441a Immutable branch for mach-at91 and power-supply for v4.20
Immutable branch between mach-at91 and power-supply for driver
 changes in at91-poweroff.
 
 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlueMkAACgkQ2O7X88g7
 +po08w/+KQXKNAcL2NXs22GOF6Yba6HrDgJuA/jorSql6iE2Rk5UIQ6biPl+0XTD
 eAMjktlJ96ybpkKP9t9JRewyFwjazfNobJA+Q9TKqrAFMsL6ytU/bdKNMERbjiZq
 GT1mtmVH76EUw2eKXsDcfksi07i5fZwmJWsWv1WeVlK22J9CQ1mOTZT9dS4nvjcv
 yeDOusQOStil9+UnOfwBh714e8Dzq17b2/YXNV9nhuUVii4NzOy4h8zOBS5nIfVm
 Q7L+4Q70xtVQEnesNqG+IyXHRMXaEOvcNVrrXlLv8wb27q13hqfNId/kBOsByzMf
 3PRWlOBOwtnNKcrFP5TmYWn8Pae1ktfC6nanjvFygF2AqMxAU/mtml51AFs/tCN3
 fLPl6bykNmreErGRsc5SPSeieEzHpoIxyPQkCNHfHBy+aa5Qp3sUzB7Y5K0G4GYp
 p+9milYWCALSkMer939UiwTyejhyET7spO1IF+yKxmY2FlPKEopOoKCVPVq/2A1a
 okuSkGq9D96BYOjz/NFmM+Lu0XVCy/ZChNp06O+59oFfSMi7rPMco410gj8QPc1h
 UfVUk/iLP3vEZv7gqDvm85f7lnLVQcT0ncbjehsCKcaL2I2rx2gozhwJi0fng0zb
 Ry1YLhkS9sQc8sZ2bGn85bMv7f42Vs9fHOwDwTQlI3k/gUQ8OU4=
 =n/Lz
 -----END PGP SIGNATURE-----

Merge tag 'psy-at91-poweroff-immutable-for-v4.20-signed' into psy-next

Immutable branch for mach-at91 and power-supply for v4.20

Immutable branch between mach-at91 and power-supply for driver
changes in at91-poweroff.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 12:37:11 +02:00
Claudiu Beznea
9f1e44774b power: reset: at91-poweroff: do not procede if at91_shdwc is allocated
There should be only one instance of struct shdwc in the system. This is
referenced through at91_shdwc. Return in probe if at91_shdwc is already
allocated.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 12:32:17 +02:00
Claudiu Beznea
d12f84906b power: reset: at91-poweroff: rename at91_shdwc_base member of struct shdwc
Rename at91_shdwc_base member of struct shdwc to shdwc_base. There is
already an "at91" string in at91_shdwc object.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 12:32:12 +02:00
Claudiu Beznea
6764aca14f power: reset: at91-poweroff: make sclk part of struct shdwc
Make sclk part of struct shdwc to have all the data specific to SHDWC
grouped together in one structure.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 12:32:09 +02:00
Claudiu Beznea
9be74f0d39 power: reset: at91-poweroff: make mpddrc_base part of struct shdwc
Make mpddrc_base part of struct shdwc since there is also only one
instance of struct shdwc *at91_shdwc in system and to have all data
specific to SHDWC grouped together.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 12:32:05 +02:00
Claudiu Beznea
4e018c1e9b power: reset: at91-poweroff: use only one poweroff function
Use only one poweroff function for sama5d2 and adapt it to work for both
scenarios (having LPDDR or not).

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 12:31:52 +02:00
Claudiu Beznea
9f7195da31 power: reset: at91-poweroff: switch to slow clock before shutdown
The SAMA5D2 NRST input signal is resynchronized with the SLCK clock and it
can take up to 2 SLCK cycles (about 90us) for the internal reset to be
effective. During this delay, the VDDCORE current consumption may still be
high (application-dependent) with the VDDCORE regulator already OFF. Under
such conditions, VDDCORE may operate below its operating range leading to
potential register corruption.

To prevent such situation, it is recommended to decrease significantly the
power consumption of the device once the voltage regulator is  turned-off.
This can be achieved by operating the device at a much lower low frequency.

To solve this switch the master clock to slock clock just before writing
shutdown command to shutdown controller.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Suggested-by: Patrice Vilchez <patrice.vilchez@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 12:31:48 +02:00
Kuninori Morimoto
b3e1b276a4 power: reset: convert to SPDX identifiers
This patch updates license to use SPDX-License-Identifier
instead of verbose license text.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 11:42:48 +02:00
Dan Carpenter
54baff8d4e power: supply: ab8500_fg: silence uninitialized variable warnings
If kstrtoul() fails then we print "charge_full" when it's uninitialized.
The debug printk doesn't add anything so I deleted it and cleaned these
two functions up a bit.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 11:40:46 +02:00
David Lechner
87a2b65fc8 power: supply: sysfs: ratelimit property read error message
This adds rate limiting to the message that is printed when reading a
power supply property via sysfs returns an error. This will prevent
userspace applications from unintentionally dDOSing the system by
continuously reading a property that returns an error.

Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 11:29:18 +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
Krzysztof Kozlowski
7b38ebdf74 power: supply: maxim: Add SPDX license identifiers
Replace GPL v2.0 and v2.0+ license statements with SPDX license
identifiers.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-08-30 00:18:10 +02:00
Ding Xiang
b00b04aa66 power: supply: ab8500_fg: fix obsolete function
simple_strtoul is obsolete, and use kstrtoint instead

Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-08-30 00:06:45 +02:00
Colin Ian King
89a74789f4 power: supply: cros_usbpd: remove unused pointer 'dev'
Pointer 'dev' is being assigned but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
variable 'dev' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-08-29 23:55:39 +02:00
Arnd Bergmann
3723c63247 treewide: convert ISO_8859-1 text comments to utf-8
Almost all files in the kernel are either plain text or UTF-8 encoded.  A
couple however are ISO_8859-1, usually just a few characters in a C
comments, for historic reasons.

This converts them all to UTF-8 for consistency.

Link: http://lkml.kernel.org/r/20180724111600.4158975-1-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Simon Horman <horms@verge.net.au>			[IPVS portion]
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>	[IIO]
Acked-by: Michael Ellerman <mpe@ellerman.id.au>			[powerpc]
Acked-by: Rob Herring <robh@kernel.org>
Cc: Joe Perches <joe@perches.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-23 18:48:43 -07:00
Linus Torvalds
c1fecabecc power supply and reset changes for the v4.19 series
* Improve support for TI bq20z75 in sbs-battery
 * Add Qualcomm PM8xxx reboot driver
 * Add cros-ec USBPD charger driver
 * Move ds2760 battery driver from w1 to power-supply and add DT support
 * Misc. fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlt8iTUACgkQ2O7X88g7
 +poDsQ//WKpd+hI0poP4X4MZ6cV3kmZH9u4Tbx1MsG7lywIE8BZZ+JQmeix9fmWp
 05reMM95zrgbWesY72/2Zpdj7G2IiNWPgaTCnBymyhcWM0y1gwM6ftHvY/Ed+pxz
 in4vjzwE0VIYK/lE64Evr1V8SqpKTtM3fco0M0snkrgyJ9FmAuT+fbnEyqNNdjHm
 hUSTRZGW6Cv1TFyhgf8bEm7s2paT5uhuABuaKYM2/XQ7PYTjF7IRA7QY871h2y6n
 9GQ7uZxtjYRTsQ5uBh1DDFuN56pvXFY1sdJxNtry+/JbQSIvzdHAVbS3mRYgbajJ
 ALfy2bKadNslbew5VSaEEswTNSZOcQ8/MNlA2o6C64mSbQ2gUfBB3wkWduO4o1jd
 uTAbCGYGCf89RocG53CieLIphK752Igd+41kkANZm0H5hu4bjNuZr1nHY1ynZSWG
 NNN1vus/IjPhd92Sx6joKHbOu9LXUukM/EQBHOGXUpgsh9zNmLnCVLLgH+jG792C
 uT3Sh4qHliWxfajd7uVR6ytALVgz6Vtp9Ry+SpOIgXMGYzcHH0x4H3Cn1gcgwu3O
 1PrTFk0+kgjZ7eOLz0X2niE3YE/+WvKKkjpf9fnimFhxppxdIA2aoJseXmYex6A2
 1tsos9wlV+Th5FAVAilq1DTKwGQ3UGTYNYbPbOaQtt9qimbCuYc=
 =UTGp
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - Improve support for TI bq20z75 in sbs-battery

 - Add Qualcomm PM8xxx reboot driver

 - Add cros-ec USBPD charger driver

 - Move ds2760 battery driver from w1 to power-supply and add DT support

 - Misc fixes

* tag 'for-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (28 commits)
  power: supply: bq27xxx: Update comments
  power: supply: max77693_charger: fix unintentional fall-through
  power: supply: mark expected switch fall-throughs
  power: supply: lego_ev3_battery: fix Vce offset
  power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value
  power: supply: ds2760_battery: add devicetree probing
  power: supply: ds2760_battery: merge ds2760 supply driver with its w1 slave companion
  w1: core: match sub-nodes of bus masters in devicetree
  dt-bindings: w1: document bindings for ds2760 battery monitor
  dt-bindings: w1: document generic onewire bindings
  power: supply: adp5061: Fix a couple off by ones
  dt-bindings: power: reset: qcom: Add resin binding
  adp5061: New driver for ADP5061 I2C battery charger
  power: generic-adc-battery: check for duplicate properties copied from iio channels
  power: generic-adc-battery: fix out-of-bounds write when copying channel properties
  power: supply: axp288_charger: Fix initial constant_charge_current value
  power: supply: ab8500: stop using getnstimeofday64()
  power: gemini-poweroff: Avoid more spurious poweroffs
  power: vexpress: fix corruption in notifier registration
  power: remove possible deadlock when unregistering power_supply
  ...
2018-08-21 18:06:27 -07:00
Sebastian Reichel
5198a48381 Merge branch 'psy-fixes' into psy-next
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2018-08-16 22:19:22 +02:00
Liu Xiang
3d779180c6 power: supply: bq27xxx: Update comments
The URL of bq27441-g1 and bq27426 are missing and bq27520-g4 is duplicated.

Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Acked-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-24 11:58:50 +02:00
Gustavo A. R. Silva
cc44ba9116 power: supply: max77693_charger: fix unintentional fall-through
It seems that a *break* is missing in order to avoid a fall-through.
Otherwise, the calculation of *data* makes no sense.

Addresses-Coverity-ID: 1271172 ("Missing break in switch")
Fixes: 87c2d90678 ("power: max77693: Add charger driver for Maxim 77693")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-23 00:14:49 +02:00
Gustavo A. R. Silva
37bab356f8 power: supply: mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 1394724 ("Missing break in switch")
Addresses-Coverity-ID: 114958 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-23 00:10:47 +02:00
David Lechner
9c7272412b power: supply: lego_ev3_battery: fix Vce offset
This fixes the value that accounts for the Vce of a transistor in the
LEGO MINDSTORMS EV3 power supply driver. The old value (200mV) was the
max value from the data sheet. After testing, the actual value has been
found to be 50mV. By using 50mV we get a more accurate voltage
indication.

Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-22 23:33:43 +02:00
David Lechner
6e92cecb1e power: supply: lego_ev3_battery: Don't ignore iio_read_channel_processed() return value
This changes the LEGO MINDSTORMS EV3 power supply driver to return an
error if iio_read_channel_processed() fails.

Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-22 23:33:43 +02:00
Sebastian Reichel
0d94990527 Immutable branch for moving ds2760 driver from w1 to power supply
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAltU+BUACgkQ2O7X88g7
 +pryvBAAk9nM8ykjerb3Xf8yGfSdFZTNxtlUBtP24g2jtkSqQKYqUfDWwkwet5Zo
 MiJ5ZpfBwZAlxisqiYziZuDFhWHtSnqMJD/tl3/pFEf/EfbfguQGK7D7X1Fi3v5q
 Mr+Zg6Qw0j3F65RDmqSGCDVg4q3+MCrEfKq4ef3gWwpqlgXPOYtnRjMwRQrC9NX5
 0O/p2ThcOuKkc1WZjNM236SgbYSTeQ2EtXzIEq13BRhzfOwh7jaLIbjAyT1M9Qwz
 kt6YsF2LHvpW2HXRbGVU6DVP7WrPaj6nL4U62O12A5Z3c9esVZpr2bEVpFhTyDXD
 rTQuqU1uUXY1bAilg+uQIAxcUmnTFPUfsvm79LcYbpcvK/j2oqL6fSY/m8PG/FG2
 U35QzLb79OvaoUBEtKk4HFo7UwVqCsZXsVNayZ59GC2HSGduN+X8LGyWIL5Wdbe2
 gVMU/telXv3DH+L0XZ0Pbvg3duhuCk6/y/SDqV55rJMy5DxoolBMQZakQMCI7hdO
 JKQHyFXRDoUbRrrsQIvkP5pP6PZt8t2IXbGjsLMX2PzAdv8CkLFTT+DF9UrWp2cM
 oyDmmO2mF1dZ1h6XWM4rELPevGwnHKYZdvdCqxH25mQB71kstCMkD2mGLNgWdCd2
 N3ofUkiD0tjJ72ktARB+O0XqJSPEqnIUVlWVmiU0lRrgGUHa+hI=
 =ufWv
 -----END PGP SIGNATURE-----

Merge tag 'ds2760-for-v4.19-signed' into psy-next

Immutable branch for moving ds2760 driver from w1 to power supply

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-22 23:33:24 +02:00
Daniel Mack
efdafd6895 power: supply: ds2760_battery: add devicetree probing
Add a matching table for devicetree probing, and optionally set the module
parameter variables from DT properties.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-11 18:09:09 +02:00
Daniel Mack
bf49735537 power: supply: ds2760_battery: merge ds2760 supply driver with its w1 slave companion
This patch removes the w1 slave driver that used to register the w1 family
and instanciate a platform device at runtime. The code now lives in the
supply driver instead to avoid that level of indirection.

The old device name "ds2760-battery.0" is preserved, so userspace
applications can access the same virtual device nodes as before.

Note that because the w1 core does not currently have a framework for
suspend/resume, the driver now registers a PM notifier callback.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-11 18:09:09 +02:00
Dan Carpenter
89b135ba1b power: supply: adp5061: Fix a couple off by ones
We end up reading one element beyond the end of the adp5061_vmax[] array
here.

Fixes: fe8e81b7e8 ("adp5061: New driver for ADP5061 I2C battery charger")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-11 12:00:24 +02:00
Randy Dunlap
ac3167257b headers: separate linux/mod_devicetable.h from linux/platform_device.h
At over 4000 #includes, <linux/platform_device.h> is the 9th most
#included header file in the Linux kernel.  It does not need
<linux/mod_devicetable.h>, so drop that header and explicitly add
<linux/mod_devicetable.h> to source files that need it.

   4146 #include <linux/platform_device.h>

After this patch, there are 225 files that use <linux/mod_devicetable.h>,
for a reduction of around 3900 times that <linux/mod_devicetable.h>
does not have to be read & parsed.

    225 #include <linux/mod_devicetable.h>

This patch was build-tested on 20 different arch-es.

It also makes these drivers SubmitChecklist#1 compliant.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kbuild test robot <lkp@intel.com> # drivers/media/platform/vimc/
Reported-by: kbuild test robot <lkp@intel.com> # drivers/pinctrl/pinctrl-u300.c
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-07 17:52:26 +02:00
Stefan Popa
fe8e81b7e8 adp5061: New driver for ADP5061 I2C battery charger
This patch adds basic support for Analog Devices I2C programmable linear
battery charger.

With this driver, some parameters can be read and configured such as:
* trickle charge current level (PRECHARGE_CURRENT)
* trickle charge voltage threshold (VOLTAGE_MIN)
* weak charge threshold (VOLTAGE_AVG)
* constant current (CONSTANT_CHARGE_CURRENT)
* constant charge voltage limit (CONSTANT_CHARGE_VOLTAGE_MAX)
* battery full (CAPACITY_LEVEL)
* input current limit (INPUT_CURRENT_LIMIT)
* charger status (STATUS)
* battery status (CAPACITY_LEVEL)
* termination current (CHARGE_TERM_CURRENT)

Datasheet:
http://www.analog.com/media/en/technical-documentation/data-sheets/ADP5061.pdf

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-06 19:36:14 +02:00
H. Nikolaus Schaller
a427503eda power: generic-adc-battery: check for duplicate properties copied from iio channels
If an iio channel defines a basic property, there are duplicate entries
in /sys/class/power/*/uevent.

So add a check to avoid duplicates. Since all channels may be duplicates,
we have to modify the related error check.

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Cc: stable@vger.kernel.org
Fixes: e60fea794e ("power: battery: Generic battery driver using IIO")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-06 18:58:44 +02:00
H. Nikolaus Schaller
932d47448c power: generic-adc-battery: fix out-of-bounds write when copying channel properties
We did have sporadic problems in the pinctrl framework during boot
where a pin group name unexpectedly became NULL leading to a NULL
dereference in strcmp.

Detailled analysis of the failing cases did reveal that there were
two devm allocated objects close to each other. The second one was
the affected group_desc in pinmux and the first one was the
psy_desc->properties buffer of the gab driver.

Review of the gab code showed that the address calculation for
one memcpy() is wrong. It does

	properties + sizeof(type) * index

but C is defined to do the index multiplication already for
pointer + integer additions. Hence the factor was applied twice
and the memcpy() does write outside of the properties buffer.
Sometimes it happened to be the pinctrl and triggered the strcmp(NULL).

Anyways, it is overkill to use a memcpy() here instead of a simple
assignment, which is easier to read and has less risk for wrong
address calculations. So we change code to a simple assignment.

If we initialize the index to the first free location, we can even
remove the local variable 'properties'.

This bug seems to exist right from the beginning in 3.7-rc1 in

commit e60fea794e ("power: battery: Generic battery driver using IIO")

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Cc: stable@vger.kernel.org
Fixes: e60fea794e ("power: battery: Generic battery driver using IIO")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-06 18:40:34 +02:00
Hans de Goede
f2a42595f0 power: supply: axp288_charger: Fix initial constant_charge_current value
We should look at val which contains the value read from the register,
not ret which is always 0 on a successful read.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Fixes: eac53b3664 ("power: supply: axp288_charger: Drop platform_data dependency")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-06 17:19:37 +02:00
Arnd Bergmann
8b0d62d49a power: supply: ab8500: stop using getnstimeofday64()
getnstimeofday64() is deprecated in favor of the ktime_get() family.

The direct replacement would be ktime_get_real_ts64(), but we only need
the seconds value, and it seems better to use boottime than real time
to avoid unexpected behavior with a concurrent settimeofday().

ktime_get_seconds() might also work, but it seems better to use
boottime than monotonic time since I assume that the charging
process continues during suspend.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-06 16:58:02 +02:00
Linus Walleij
ada1de89f3 power: gemini-poweroff: Avoid more spurious poweroffs
Even after the previous fix I have experienced more spurious
poweroffs on the gemini SoC. After this fix it finally seems
to go away.

Fixes: f7a388d6cd ("power: reset: Add a driver for the Gemini poweroff")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-06 16:34:01 +02:00
Sudeep Holla
09bebb1adb power: vexpress: fix corruption in notifier registration
Vexpress platforms provide two different restart handlers: SYS_REBOOT
that restart the entire system, while DB_RESET only restarts the
daughter board containing the CPU. DB_RESET is overridden by SYS_REBOOT
if it exists.

notifier_chain_register used in register_restart_handler by design
relies on notifiers to be registered once only, however vexpress restart
notifier can get registered twice. When this happen it corrupts list
of notifiers, as result some notifiers can be not called on proper
event, traverse on list can be cycled forever, and second unregister
can access already freed memory.

So far, since this was the only restart handler in the system, no issue
was observed even if the same notifier was registered twice. However
commit 6c5c0d48b6 ("watchdog: sp805: add restart handler") added
support for SP805 restart handlers and since the system under test
contains two vexpress restart and two SP805 watchdog instances, it was
observed that during the boot traversing the restart handler list looped
forever as there's a cycle in that list resulting in boot hang.

This patch fixes the issues by ensuring that the notifier is installed
only once.

Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Fixes: 46c99ac662 ("power/reset: vexpress: Register with kernel restart handler")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-06 16:23:45 +02:00
Benjamin Tissoires
3ffa6583e2 power: remove possible deadlock when unregistering power_supply
If a device gets removed right after having registered a power_supply node,
we might enter in a deadlock between the remove call (that has a lock on
the parent device) and the deferred register work.

Allow the deferred register work to exit without taking the lock when
we are in the remove state.

Stack trace on a Ubuntu 16.04:

[16072.109121] INFO: task kworker/u16:2:1180 blocked for more than 120 seconds.
[16072.109127]       Not tainted 4.13.0-41-generic #46~16.04.1-Ubuntu
[16072.109129] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[16072.109132] kworker/u16:2   D    0  1180      2 0x80000000
[16072.109142] Workqueue: events_power_efficient power_supply_deferred_register_work
[16072.109144] Call Trace:
[16072.109152]  __schedule+0x3d6/0x8b0
[16072.109155]  schedule+0x36/0x80
[16072.109158]  schedule_preempt_disabled+0xe/0x10
[16072.109161]  __mutex_lock.isra.2+0x2ab/0x4e0
[16072.109166]  __mutex_lock_slowpath+0x13/0x20
[16072.109168]  ? __mutex_lock_slowpath+0x13/0x20
[16072.109171]  mutex_lock+0x2f/0x40
[16072.109174]  power_supply_deferred_register_work+0x2b/0x50
[16072.109179]  process_one_work+0x15b/0x410
[16072.109182]  worker_thread+0x4b/0x460
[16072.109186]  kthread+0x10c/0x140
[16072.109189]  ? process_one_work+0x410/0x410
[16072.109191]  ? kthread_create_on_node+0x70/0x70
[16072.109194]  ret_from_fork+0x35/0x40
[16072.109199] INFO: task test:2257 blocked for more than 120 seconds.
[16072.109202]       Not tainted 4.13.0-41-generic #46~16.04.1-Ubuntu
[16072.109204] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[16072.109206] test            D    0  2257   2256 0x00000004
[16072.109208] Call Trace:
[16072.109211]  __schedule+0x3d6/0x8b0
[16072.109215]  schedule+0x36/0x80
[16072.109218]  schedule_timeout+0x1f3/0x360
[16072.109221]  ? check_preempt_curr+0x5a/0xa0
[16072.109224]  ? ttwu_do_wakeup+0x1e/0x150
[16072.109227]  wait_for_completion+0xb4/0x140
[16072.109230]  ? wait_for_completion+0xb4/0x140
[16072.109233]  ? wake_up_q+0x70/0x70
[16072.109236]  flush_work+0x129/0x1e0
[16072.109240]  ? worker_detach_from_pool+0xb0/0xb0
[16072.109243]  __cancel_work_timer+0x10f/0x190
[16072.109247]  ? device_del+0x264/0x310
[16072.109250]  ? __wake_up+0x44/0x50
[16072.109253]  cancel_delayed_work_sync+0x13/0x20
[16072.109257]  power_supply_unregister+0x37/0xb0
[16072.109260]  devm_power_supply_release+0x11/0x20
[16072.109263]  release_nodes+0x110/0x200
[16072.109266]  devres_release_group+0x7c/0xb0
[16072.109274]  wacom_remove+0xc2/0x110 [wacom]
[16072.109279]  hid_device_remove+0x6e/0xd0 [hid]
[16072.109284]  device_release_driver_internal+0x158/0x210
[16072.109288]  device_release_driver+0x12/0x20
[16072.109291]  bus_remove_device+0xec/0x160
[16072.109293]  device_del+0x1de/0x310
[16072.109298]  hid_destroy_device+0x27/0x60 [hid]
[16072.109303]  usbhid_disconnect+0x51/0x70 [usbhid]
[16072.109308]  usb_unbind_interface+0x77/0x270
[16072.109311]  device_release_driver_internal+0x158/0x210
[16072.109315]  device_release_driver+0x12/0x20
[16072.109318]  usb_driver_release_interface+0x77/0x80
[16072.109321]  proc_ioctl+0x20f/0x250
[16072.109325]  usbdev_do_ioctl+0x57f/0x1140
[16072.109327]  ? __wake_up+0x44/0x50
[16072.109331]  usbdev_ioctl+0xe/0x20
[16072.109336]  do_vfs_ioctl+0xa4/0x600
[16072.109339]  ? vfs_write+0x15a/0x1b0
[16072.109343]  SyS_ioctl+0x79/0x90
[16072.109347]  entry_SYSCALL_64_fastpath+0x24/0xab
[16072.109349] RIP: 0033:0x7f20da807f47
[16072.109351] RSP: 002b:00007ffc422ae398 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[16072.109353] RAX: ffffffffffffffda RBX: 00000000010b8560 RCX: 00007f20da807f47
[16072.109355] RDX: 00007ffc422ae3a0 RSI: 00000000c0105512 RDI: 0000000000000009
[16072.109356] RBP: 0000000000000000 R08: 00007ffc422ae3e0 R09: 0000000000000010
[16072.109357] R10: 00000000000000a6 R11: 0000000000000246 R12: 0000000000000000
[16072.109359] R13: 00000000010b8560 R14: 00007ffc422ae2e0 R15: 0000000000000000

Reported-and-tested-by: Richard Hughes <rhughes@redhat.com>
Tested-by: Aaron Skomra <Aaron.Skomra@wacom.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Fixes: 7f1a57fdd6 ("power_supply: Fix possible NULL pointer dereference on early uevent")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-06 16:03:21 +02:00
Vinod Koul
e6a578e289 power: reset: qcom-pon: Add Qcom PON driver
Add support Qualcomm PM8xxx PON which is responsible for reboot
mode support.

Co-developed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-06 15:53:58 +02:00
Sameer Nanda
f68b883e8f power: supply: add cros-ec USBPD charger driver.
This driver gets various bits of information about what is connected to
USB PD ports from the EC and converts that into power_supply properties.

Signed-off-by: Sameer Nanda <snanda@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-05 17:12:52 +02:00
Colin Ian King
1d45d2d2fd power: supply: max1721x: fix spelling mistake "RSenese" -> "RSense"
Trivial fix to spelling mistake in dev_warn message text

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-06-28 14:24:13 +02:00
Alexey Khoroshilov
f052df96c4 power: reset: zx-reboot: put device node in zx_reboot_probe()
zx_reboot_probe() increments refcnt of zx296702-pcu device node by
of_find_compatible_node() and leaves it undecremented on both
successful and error paths.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: Nicholas Mc Guire <der.herr@hofr.at>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-06-28 14:20:38 +02:00
Enric Balletbo i Serra
91937b1478 power: supply: tps65217: Switch to SPDX identifier.
Adopt the SPDX license identifier headers to ease license compliance
management.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-06-28 14:19:20 +02:00
Brian Norris
76b16f4cdf power: supply: sbs-battery: don't assume MANUFACTURER_DATA formats
This driver was originally submitted for the TI BQ20Z75 battery IC
(commit a7640bfa10 ("power_supply: Add driver for TI BQ20Z75 gas gauge
IC")) and later renamed to express generic SBS support. While it's
mostly true that this driver implemented a standard SBS command set, it
takes liberties with the REG_MANUFACTURER_DATA register. This register
is specified in the SBS spec, but it doesn't make any mention of what
its actual contents are.

We've sort of noticed this optionality previously, with commit
17c6d3979e ("sbs-battery: make writes to ManufacturerAccess
optional"), where we found that some batteries NAK writes to this
register.

What this really means is that so far, we've just been lucky that most
batteries have either been compatible with the TI chip, or else at least
haven't reported highly-unexpected values.

For instance, one battery I have here seems to report either 0x0000 or
0x0100 to the MANUFACTURER_ACCESS_STATUS command -- while this seems to
match either Wake Up (bits[11:8] = 0000b) or Normal Discharge
(bits[11:8] = 0001b) status for the TI part [1], they don't seem to
actually correspond to real states (for instance, I never see 0101b =
Charge, even when charging).

On other batteries, I'm getting apparently random data in return, which
means that occasionally, we interpret this as "battery not present" or
"battery is not healthy".

All in all, it seems to be a really bad idea to make assumptions about
REG_MANUFACTURER_DATA, unless we already know what battery we're using.
Therefore, this patch reimplements the "present" and "health" checks to
the following on most SBS batteries:

1. HEALTH: report "unknown" -- I couldn't find a standard SBS command
   that gives us much useful here
2. PRESENT: just send a REG_STATUS command; if it succeeds, then the
   battery is present

Also, we stop sending MANUFACTURER_ACCESS_SLEEP to non-TI parts. I have
no proof that this is useful and supported.

If someone explicitly provided a 'ti,bq20z75' compatible property, then
we continue to use the existing TI command behaviors, and we effectively
revert commit 17c6d3979e ("sbs-battery: make writes to
ManufacturerAccess optional") to again make these commands required.

[1] http://www.ti.com/lit/er/sluu265a/sluu265a.pdf

Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-06-28 14:09:46 +02:00
Kees Cook
a86854d0c5 treewide: devm_kzalloc() -> devm_kcalloc()
The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
This patch replaces cases of:

        devm_kzalloc(handle, a * b, gfp)

with:
        devm_kcalloc(handle, a * b, gfp)

as well as handling cases of:

        devm_kzalloc(handle, a * b * c, gfp)

with:

        devm_kzalloc(handle, array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        devm_kcalloc(handle, array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        devm_kzalloc(handle, 4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

Some manual whitespace fixes were needed in this patch, as Coccinelle
really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
expression HANDLE;
type TYPE;
expression THING, E;
@@

(
  devm_kzalloc(HANDLE,
-	(sizeof(TYPE)) * E
+	sizeof(TYPE) * E
  , ...)
|
  devm_kzalloc(HANDLE,
-	(sizeof(THING)) * E
+	sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression HANDLE;
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(u8) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(__u8) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(char) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(unsigned char) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(u8) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(__u8) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(char) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(unsigned char) * COUNT
+	COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
expression HANDLE;
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (COUNT_ID)
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * COUNT_ID
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (COUNT_CONST)
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * COUNT_CONST
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (COUNT_ID)
+	COUNT_ID, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * COUNT_ID
+	COUNT_ID, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (COUNT_CONST)
+	COUNT_CONST, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * COUNT_CONST
+	COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
expression HANDLE;
identifier SIZE, COUNT;
@@

- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	SIZE * COUNT
+	COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression HANDLE;
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression HANDLE;
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
expression HANDLE;
identifier STRIDE, SIZE, COUNT;
@@

(
  devm_kzalloc(HANDLE,
-	(COUNT) * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression HANDLE;
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * (E2) * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * (E2) * (E3)
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	E1 * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression HANDLE;
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
|
  devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
|
  devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
  devm_kzalloc(HANDLE, C1 * C2, ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (E2)
+	E2, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * E2
+	E2, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (E2)
+	E2, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * E2
+	E2, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	(E1) * E2
+	E1, E2
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	(E1) * (E2)
+	E1, E2
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	E1 * E2
+	E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 16:19:22 -07:00
Kees Cook
6396bb2215 treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:

        kzalloc(a * b, gfp)

with:
        kcalloc(a * b, gfp)

as well as handling cases of:

        kzalloc(a * b * c, gfp)

with:

        kzalloc(array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        kzalloc_array(array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        kzalloc(4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@

(
  kzalloc(
-	(sizeof(TYPE)) * E
+	sizeof(TYPE) * E
  , ...)
|
  kzalloc(
-	(sizeof(THING)) * E
+	sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  kzalloc(
-	sizeof(u8) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(__u8) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(char) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(unsigned char) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(u8) * COUNT
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(__u8) * COUNT
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(char) * COUNT
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(unsigned char) * COUNT
+	COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * (COUNT_ID)
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * COUNT_ID
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * (COUNT_CONST)
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * COUNT_CONST
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * (COUNT_ID)
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * COUNT_ID
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * (COUNT_CONST)
+	COUNT_CONST, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * COUNT_CONST
+	COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@

- kzalloc
+ kcalloc
  (
-	SIZE * COUNT
+	COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  kzalloc(
-	sizeof(TYPE) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(TYPE) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(TYPE) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(TYPE) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(THING) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
-	sizeof(THING) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
-	sizeof(THING) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
-	sizeof(THING) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  kzalloc(
-	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kzalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kzalloc(
-	sizeof(THING1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kzalloc(
-	sizeof(THING1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kzalloc(
-	sizeof(TYPE1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  kzalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@

(
  kzalloc(
-	(COUNT) * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	(COUNT) * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	(COUNT) * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	(COUNT) * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  kzalloc(C1 * C2 * C3, ...)
|
  kzalloc(
-	(E1) * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
-	(E1) * (E2) * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
-	(E1) * (E2) * (E3)
+	array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
-	E1 * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  kzalloc(sizeof(THING) * C2, ...)
|
  kzalloc(sizeof(TYPE) * C2, ...)
|
  kzalloc(C1 * C2 * C3, ...)
|
  kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * (E2)
+	E2, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * E2
+	E2, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * (E2)
+	E2, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * E2
+	E2, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	(E1) * E2
+	E1, E2
  , ...)
|
- kzalloc
+ kcalloc
  (
-	(E1) * (E2)
+	E1, E2
  , ...)
|
- kzalloc
+ kcalloc
  (
-	E1 * E2
+	E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 16:19:22 -07:00
Linus Torvalds
a16afaf792 power supply and reset changes for the v4.18 series
* bq27xxx: Add BQ27426 support
 * ab8500: Drop AB8540/9540 support
 * Introduced new usb_type property
 * Properly document the power-supply ABI
 * misc. cleanups and fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlscFLIACgkQ2O7X88g7
 +pplkA/+OU3V/sFfbHka6RdoIVeEJCqtQnd1d3VimbKmSpCZQ9W5SnJoc/Dzy3+q
 Di0mrFb9nB77H4ShMVVc/rAy4flv7copnI2SJDZ1psx4pX4LS7AwToAlQY1Cr/VR
 QBStyZ4aJrvHtdPYggZADAwiU3/vBtI14n28/8TdGlsHFszVbcr2IhiUBYiVgb++
 jvQCQyKbxgMfou08wV2Sg/moKXGFh+1HtobRZDyr4Su3A1Nyr6Epyg8gBADi2ZgS
 nWaGfYfpI9gaA7g00y/OvqTZroJD+WKAToecl5frgtZ+zHZAQsVGJth9f+LrYXlz
 7bERZf94L8MwRNz1Zl8nJ+zHfOmMjEFerHCI81+6wO+klcAgv5AQTcP11a+oZWiQ
 5Isq6yt6meg2B4XfBX2EcnXtztnvgb0+lb0KaRUhiQ/5BzupsyIBw8vlJmilGP61
 DmL63WrXSb2XChnAkfLbLiKXethY4/y7WjHxPv7esJqy1X6tpFURHwoopv/HWX6N
 ctsqOp1D3pl+pBQvOZ4g5oWMTwmlu1uUsKXaZpOYx7+a8CIfJxPVXB+S/D3C5YsU
 U1KodhtmhXp8FmbyH1OufARXk9G9rievgOLAPTfsjet06rwpLdy6iLeztvjZIo+T
 H5pvkD+1o4P6TiAgsPTnOK9YXGL/Pr4rb2voiu7sKLRAfBr65ww=
 =UB16
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:
 - bq27xxx: Add BQ27426 support
 - ab8500: Drop AB8540/9540 support
 - Introduced new usb_type property
 - Properly document the power-supply ABI
 - misc. cleanups and fixes

* tag 'for-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  MAINTAINERS: add entry for LEGO MINDSTORMS EV3
  power: supply: ab8500_charger: fix spelling mistake: "faile" -> "failed"
  power: supply: axp288_fuel_gauge: Remove polling from the driver
  power: supply: axp288_fuelguage: Do not bind when the fg function is not used
  power: supply: axp288_charger: Do not bind when the charge function is not used
  power: supply: axp288_charger: Support 3500 and 4000 mA input current limit
  power: supply: s3c-adc-battery: fix driver data initialization
  power: supply: charger-manager: Verify polling interval only when polling requested
  power: supply: sysfs: Use enum to specify property
  power: supply: ab8500: Drop AB8540/9540 support
  power: supply: ab8500_fg: fix spelling mistake: "Disharge" -> "Discharge"
  power: supply: simplify getting .drvdata
  power: supply: bq27xxx: Add support for BQ27426
  gpio-poweroff: Use gpiod_set_value_cansleep
2018-06-09 12:11:09 -07:00
Linus Torvalds
07c4dd3435 USB/PHY patches for 4.18-rc1
Here is the big USB pull request for 4.18-rc1.
 
 Lots of stuff here, the highlights are:
 	- phy driver updates and new additions
 	- usual set of xhci driver updates
 	- normal set of musb updates
 	- gadget driver updates and new controllers
 	- typec work, it's getting closer to getting fully out of the
 	  staging portion of the tree.
 	- lots of minor cleanups and bugfixes.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWxba6w8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ykumQCg2abWE5LijR0SNJIwX8xk64HLUAMAnAxBZDG3
 aB0GyOQd54L+09q4LAdn
 =ZCEx
 -----END PGP SIGNATURE-----

Merge tag 'usb-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB and PHY updates from Greg KH:
 "Here is the big USB pull request for 4.18-rc1.

  Lots of stuff here, the highlights are:

   - phy driver updates and new additions

   - usual set of xhci driver updates

   - normal set of musb updates

   - gadget driver updates and new controllers

   - typec work, it's getting closer to getting fully out of the staging
     portion of the tree.

   - lots of minor cleanups and bugfixes.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'usb-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits)
  Revert "xhci: Reset Renesas uPD72020x USB controller for 32-bit DMA issue"
  xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers
  xhci: Allow more than 32 quirks
  usb: xhci: force all memory allocations to node
  selftests: add test for USB over IP driver
  USB: typec: fsusb302: no need to check return value of debugfs_create_dir()
  USB: gadget: udc: s3c2410_udc: no need to check return value of debugfs_create functions
  USB: gadget: udc: renesas_usb3: no need to check return value of debugfs_create functions
  USB: gadget: udc: pxa27x_udc: no need to check return value of debugfs_create functions
  USB: gadget: udc: gr_udc: no need to check return value of debugfs_create functions
  USB: gadget: udc: bcm63xx_udc: no need to check return value of debugfs_create functions
  USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions
  USB: dwc3: no need to check return value of debugfs_create functions
  USB: dwc2: no need to check return value of debugfs_create functions
  USB: core: no need to check return value of debugfs_create functions
  USB: chipidea: no need to check return value of debugfs_create functions
  USB: ehci-hcd: no need to check return value of debugfs_create functions
  USB: fhci-hcd: no need to check return value of debugfs_create functions
  USB: fotg210-hcd: no need to check return value of debugfs_create functions
  USB: imx21-hcd: no need to check return value of debugfs_create functions
  ...
2018-06-05 16:14:12 -07:00
Adam Thomson
ece711b5a4 power: supply: Add fwnode pointer to power_supply_config struct
To allow users of the power supply framework to be hw description
agnostic, this commit adds the ability to pass a fwnode pointer,
via the power_supply_config structure, to the initialisation code
of the core, instead of explicitly specifying of_ndoe. If that
fwnode pointer is provided then it will automatically resolve down
to of_node on platforms which support it, otherwise it will be NULL.

In the future, when ACPI support is added, this can be modified to
accommodate ACPI without the need to change calling code which
already provides the fwnode handle in this manner.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-24 18:14:27 +02:00
David Wu
b8281fa71d PM / AVS: rockchip-io: add io selectors and supplies for PX30
This adds the necessary data for handling io voltage domains on PX30.
As interesting tidbit, the PX30 contains two separate iodomain areas.
One in the regular General Register Files (GRF) and one in PMUGRF in the
pmu power domain.

Signed-off-by: David Wu <david.wu@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-05-17 12:40:12 +02:00
Colin Ian King
b5e11cc109 power: supply: ab8500_charger: fix spelling mistake: "faile" -> "failed"
trivial fix to spelling mistake in dev_error message.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-05-01 13:31:38 +02:00
Sebastian Reichel
1f140ff467 Tag/Merge point for adding typeC power supply support
This is a signed tag/merge point to handle the cross-tree merge of the
 USB and power supply subsystems for the patch series:
 	Subject: [PATCH v8 0/6] typec: tcpm: Add sink side support for PPS
 
 It is based on the usb.git tree, in the usb-next branch, for merging in
 4.18-rc1.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWuGASg8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylqPACcDdrowGIQp0vVa7VrOJNMy9pL5K0An1cjnaUt
 0sXkKK8YWC3EQSSYtr3Q
 =McRU
 -----END PGP SIGNATURE-----

Merge tag 'tags/tcpm-pps-4.18' into psy-next

Tag/Merge point for adding typeC power supply support

This is a signed tag/merge point to handle the cross-tree merge of the
USB and power supply subsystems for the patch series:
	Subject: [PATCH v8 0/6] typec: tcpm: Add sink side support for PPS

It is based on the usb.git tree, in the usb-next branch, for merging in
4.18-rc1.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26 12:18:30 +02:00
Hans de Goede
a78c0c30ec power: supply: axp288_fuel_gauge: Remove polling from the driver
Userspace class/power_supply consumers such as upower, already know some
supplies need to be polled to get up2date info. Doing this in the kernel
and then waking up userspace just causes unnecessary wakeups and i2c
transfers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26 00:49:52 +02:00
Hans de Goede
04d6f72f68 power: supply: axp288_fuelguage: Do not bind when the fg function is not used
Some devices with an AXP288 PMIC do not have a battery at all, or use
external charger and fuelgauge ICs instead of the AXP288 builtin
functionality.

On such devices we should not bind to the fuelgauge function to avoid
exporting a non working power_supply class device.

This also avoids the following errors repeating over and over again in
dmesg:

axp288_fuel_gauge axp288_fuel_gauge: capacity measurement not valid
axp288_fuel_gauge axp288_fuel_gauge: Error 0xe2 contents not valid
power_supply axp288_fuel_gauge: driver failed to report 'charge_now'
property: -6

Cc: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26 00:44:52 +02:00
Hans de Goede
efb440ecc1 power: supply: axp288_charger: Do not bind when the charge function is not used
Some devices with an AXP288 PMIC do not have a battery at all, or use
external charger and fuelgauge ICs instead of the AXP288 builtin
functionality.

On such devices we should not bind to the charge function to avoid
exporting a non working power_supply class device.

Cc: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26 00:44:40 +02:00
Hans de Goede
5b76ad50d2 power: supply: axp288_charger: Support 3500 and 4000 mA input current limit
The AXP288 supports an input-current-limit of up to 4000 mA, this
commit adds support for the 3500 and 4000 mA settings which were
missing until now.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26 00:44:27 +02:00
Sergiy Kibrik
2490640b27 power: supply: s3c-adc-battery: fix driver data initialization
For power_supply_get_drvdata() routine to work correctly the driver data
has to be provided when registering power supply, otherwise driver gives up
immediately with these errors:

  power_supply main-battery: no battery infos ?!
  power_supply main-battery: driver failed to report `status' property: -22

Signed-off-by: Sergiy Kibrik <sakib@darkstar.site>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26 00:12:11 +02:00
Ladislav Michl
111242d6e1 power: supply: charger-manager: Verify polling interval only when polling requested
Driver bails out with -EINVAL when no polling specififaion is requested.
Fix that by verifing polling interval only if polling_mode is different
from CM_POLL_DISABLE.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-26 00:01:27 +02:00
Ladislav Michl
39b4fb8056 power: supply: sysfs: Use enum to specify property
Power supply property is in fact enum, so reflect it in code.
Also use switch statement in show property function as is done
for storing property.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25 23:53:57 +02:00
Linus Walleij
4c4268dc97 power: supply: ab8500: Drop AB8540/9540 support
The AB8540 was an evolved version of the AB8500, but it was never
mass produced or put into products, only reference designs exist.
The upstream support was never completed and it is unlikely that
this will happen so drop the support for now to simplify
maintenance of the AB8500.

Cc: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25 23:49:44 +02:00
Colin Ian King
8c2fac99f2 power: supply: ab8500_fg: fix spelling mistake: "Disharge" -> "Discharge"
Trivial fix to spelling mistake in dev_dbg message text

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25 23:46:24 +02:00
Wolfram Sang
bb772d0fdf power: supply: simplify getting .drvdata
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25 23:15:51 +02:00
Andrew F. Davis
5ef6a16033 power: supply: bq27xxx: Add support for BQ27426
This device is software similar to the BQ27426 except it has
different data memory offsets. Add support here.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25 23:11:47 +02:00
Mike Looijmans
77142a6112 gpio-poweroff: Use gpiod_set_value_cansleep
The power-off call is done in a context that must be able to sleep, so
use gpiod_set_value_cansleep instead of the atomic gpiod_set_value call.

This fixes a kernel warning at shutdown when the gpio is controlled
through an IO expander for example.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-04-25 23:05:59 +02:00
Adam Thomson
cf45004195 power: supply: Add 'usb_type' property and supporting code
This commit adds the 'usb_type' property to represent USB supplies
which can report a number of different types based on a connection
event.

Examples of this already exist in drivers whereby the existing 'type'
property is updated, based on an event, to represent what was
connected (e.g. USB, USB_DCP, USB_ACA, ...). Current implementations
however don't show all supported connectable types, so this knowledge
has to be exlicitly known for each driver that supports this.

The 'usb_type' property is intended to fill this void and show users
all possible USB types supported by a driver. The property, when read,
shows all available types for the driver, and the one currently chosen
is highlighted/bracketed. It is expected that the 'type' property
would then just show the top-level type 'USB', and this would be
static.

Currently the 'usb_type' enum contains all of the USB variant types
that exist for the 'type' enum at this time, and in addition has
SDP and PPS types. The mirroring is intentional so as to not impact
existing usage of the 'type' property.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-25 14:17:48 +02:00
Adam Thomson
1ac3eef74a power: supply: Add error checking of psy desc during registration
Currently there's no error checking of this parameter in the
registration function and it's blindly added to psy class and
subsequently used as is. For example if this is NULL the call
to psy_register_thermal() will try to dereference the pointer
thus causing a kernel dump.

This commit updates the registration code to add some basic
checks on the desc pointer validity, name, and presence of
properties.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-25 14:17:48 +02:00
Linus Torvalds
167569343f ARM: SoC platform updates for 4.17
This release brings up a new platform based on the old ARM9 core: the
 Nuvoton NPCM is used as a baseboard management controller, competing
 with the better known ASpeed AST2xx series.
 
 Another important change is the addition of ARMv7-A based chips
 in mach-stm32. The older parts in this platform are ARMv7-M based
 microcontrollers, now they are expanding to general-purpose workloads.
 
 The other changes are the usual defconfig updates to enable additional
 drivers, lesser bugfixes. The largest updates as often are the ongoing
 OMAP cleanups, but we also have a number of changes for the older
 PXA and davinci platforms this time.
 
 For the Renesas shmobile/r-car platform, some new infrastructure
 is needed to make the watchdog work correctly.
 
 Supporting Multiprocessing on Allwinner A80 required a significant
 amount of new code, but is not doing anything unexpected.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJaxibSAAoJEGCrR//JCVInPwcP/2ZdLMXXXaJBM+rCRPhT+vR1
 FsKqcTCC5RHbVcKW+N54nmlsqofy2GadlmyfOdrFXtbf+Sm2dRNsDrHDOhvoPp37
 fwBd0wGw0PLjNE8SEPp/ldtFe11Dbg0WGBzJ4PAPJgt1W4hvW8//VzVW1XsiRrVc
 9SlZ66DwR95UQ5pwy+dfE8f9A/WW4XaMq0UHQ3/deQ/Te/64b/C6CJtT3W73WAlR
 83UHgkwq3WvI+hhvg4QX9H0Q6dcK2JLUWsAB0xnZP8Q8t30NdDpl61uZL0A4Mh9Y
 38lPhUjPUyUpsGrOttmMEQNzbAk4m/nzQxByYYmhkx3x+mlhjdA9KNavxDYVxXN2
 1tzz62wst8pLePqVt2UsFqsaruJGMuTIooOdc5iCjG1c2N2kQGdBsuOvLjYu9kV6
 XPTfvvAYkMo9rC0MbdPuobG+h/WrYHuc9SD2Mnt+kNaw1yJL08fWENjSuwP7kheb
 2A5jdAFNrGqgcrWMsQOw8eYYC7z7WojkLq0kHrBbwIlVD7KIZurv2fm/iVo4+xPH
 Gig5HuehMUtVYAf+Q1KWFlqS01fXMErt2pDGI5f1mNumXCB5kdWoSKbU8lOg03f8
 ZqBHlfly+QDMOx0qfkxFX+phHPWHTOC+45yHK2Xq+n9urXmQbzYZxTzq5zCu6jcm
 4yH0jaykoHODGNLIt50f
 =HD9V
 -----END PGP SIGNATURE-----

Merge tag 'armsoc-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc

Pull ARM SoC platform updates from Arnd Bergmann:
 "This release brings up a new platform based on the old ARM9 core: the
  Nuvoton NPCM is used as a baseboard management controller, competing
  with the better known ASpeed AST2xx series.

  Another important change is the addition of ARMv7-A based chips in
  mach-stm32. The older parts in this platform are ARMv7-M based
  microcontrollers, now they are expanding to general-purpose workloads.

  The other changes are the usual defconfig updates to enable additional
  drivers, lesser bugfixes. The largest updates as often are the ongoing
  OMAP cleanups, but we also have a number of changes for the older PXA
  and davinci platforms this time.

  For the Renesas shmobile/r-car platform, some new infrastructure is
  needed to make the watchdog work correctly.

  Supporting Multiprocessing on Allwinner A80 required a significant
  amount of new code, but is not doing anything unexpected"

* tag 'armsoc-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (179 commits)
  arm: npcm: modify configuration for the NPCM7xx BMC.
  MAINTAINERS: update entry for ARM/berlin
  ARM: omap2: fix am43xx build without L2X0
  ARM: davinci: da8xx: simplify CFGCHIP regmap_config
  ARM: davinci: da8xx: fix oops in USB PHY driver due to stack allocated platform_data
  ARM: multi_v7_defconfig: add NXP FlexCAN IP support
  ARM: multi_v7_defconfig: enable thermal driver for i.MX devices
  ARM: multi_v7_defconfig: add RN5T618 PMIC family support
  ARM: multi_v7_defconfig: add NXP graphics drivers
  ARM: multi_v7_defconfig: add GPMI NAND controller support
  ARM: multi_v7_defconfig: add OCOTP driver for NXP SoCs
  ARM: multi_v7_defconfig: configure I2C driver built-in
  arm64: defconfig: add CONFIG_UNIPHIER_THERMAL and CONFIG_SNI_AVE
  ARM: imx: fix imx6sll-only build
  ARM: imx: select ARM_CPU_SUSPEND for CPU_IDLE as well
  ARM: mxs_defconfig: Re-sync defconfig
  ARM: imx_v4_v5_defconfig: Use the generic fsl-asoc-card driver
  ARM: imx_v4_v5_defconfig: Re-sync defconfig
  arm64: defconfig: enable stmmac ethernet to defconfig
  ARM: EXYNOS: Simplify code in coupled CPU idle hot path
  ...
2018-04-05 21:21:08 -07:00
Linus Torvalds
3ac684b881 power supply and reset changes for the v4.17 series
* Microsemi Ocelot reset support
 * Spreadtrum SC27xx reset support
 * generic gpio charger: lot's of cleanups
 * axp20x fuel gauge: add AXP813 support
 * misc. fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlrCZVQACgkQ2O7X88g7
 +ppKgQ/8Cmgfta6nX5N8U3jAbBmduFkxmV+WaVE2yMned7ABL5ZAXBOBIDXW0Cvk
 yFNhu4fgpb2tDW/NEsYiyu61ES7F4W+q0AlvTNaPcM4oh+j8+E3B8C26qUaojw7E
 rB5FrRJA7/1RQeBl8RrWplT3bmYyL8qPrEca3hPPrrVPYsvf7TqJlgJRqOEu5bIG
 GBcU+aPZsd6T0u3SloErm0LL9Q4S6YpuW/gqR69azcQUacfalA7kjZ5gpiN9YXYq
 xSsm3zoJl77x4HTAnKN+7Kzyl3gugKJXIN8kN19F9iYwpc3ccii9FROrx7T3trps
 nUojvRorlZHawwAOYxp/6C21u6N7SXZ+TyVnPWgjP24Fr7DI5OxqWEZ8fZqaN7M4
 nNjhZYpquJDwgg63E1WoA3aPOUCQp7ZLz2xKUWuwX6n1zXr/R3qVeguFPORvhp9Q
 uu9nfoZXo5ThVz5JK5eGP7pE1OU/qpnzF2ZLHyeNULjAJcnxQjNzN2nTG35IxiO0
 BKlYmy31GcMwooRqarJrKavzMU1xGKZtIGxOm6uIluqA1cGfH+8ahk84tzLgYAZ4
 4MYnPjDyR31gzt9AB3eb7wGo+TP7djnIzeooeyz8Q71oNcCx263QgrmaKcPZjQtm
 QcLA+/jyGNg0T5t6l2Kj7mLKNdiGb6bHMqMs5KrezTruJcDhlRg=
 =VY8H
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - Microsemi Ocelot reset support

 - Spreadtrum SC27xx reset support

 - generic gpio charger: lot's of cleanups

 - axp20x fuel gauge: add AXP813 support

 - misc fixes, including one devicetree change for the Nokia N900, that
   has been Acked-by Tony Lindgren

* tag 'for-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (27 commits)
  power: reset: at91-reset: Switch from the pr_*() to the dev_*() logging functions
  power: reset: at91-poweroff: Remove redundant dev_err call in at91_poweroff_probe()
  power: reset: at91-poweroff: Switch from the pr_*() to the dev_*() logging functions
  power: reset: make function sc27xx_poweroff_shutdown static
  power: supply: da9150-fg: remove VLA usage
  ARM: dts: omap3-n900: Add link between battery and charger
  power: supply: bq2415x: add DT referencing support
  power: supply: bq27xxx: support missing supplier device
  max17042: propagate of_node to power supply device
  power: supply: axp288_fuel_gauge: Fix full status reporting
  power: supply: axp288_fuel_gauge: Do not register FG on ECS EF20EA
  power: reset: gpio-poweroff: Support for timeout from device property
  dt-bindings: power: reset: gpio-poweroff: Add 'timeout-ms' property
  power: reset: Add Spreadtrum SC27xx PMIC power off support
  power: supply: axp20x_battery: add support for AXP813
  dt-bindings: power: supply: axp20x: add AXP813 battery DT binding
  power: supply: axp20x_battery: use data struct for variant specific code
  power: supply: gpio-charger: Remove pdata from gpio_charger
  power: supply: gpio-charger: Use GPIOF_ACTIVE_LOW for legacy setup
  power: supply: gpio-charger: Remove redundant dev_err call in probe function
  ...
2018-04-03 12:10:01 -07:00
Ladislav Michl
fd73a3e618 power: reset: at91-reset: Switch from the pr_*() to the dev_*() logging functions
Use dev_info() instead of pr_info().

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-19 20:51:17 +01:00
Ladislav Michl
ab08824826 power: reset: at91-poweroff: Remove redundant dev_err call in at91_poweroff_probe()
There is an error message within devm_ioremap_resource
already, so remove the dev_err call to avoid redundancy.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-19 20:50:51 +01:00
Ladislav Michl
062836db01 power: reset: at91-poweroff: Switch from the pr_*() to the dev_*() logging functions
Use dev_info() instead of pr_info().

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-19 20:50:24 +01:00
Colin Ian King
93619fdec9 power: reset: make function sc27xx_poweroff_shutdown static
The function sc27xx_poweroff_shutdown is local to the source and does
not need to be in global scope, so make it static.

Cleans up sparse warning:
drivers/power/reset/sc27xx-poweroff.c:28:6: warning: symbol
'sc27xx_poweroff_shutdown' was not declared. Should it be static?

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-13 12:10:04 +01:00
Sebastian Reichel
75dd56c0cd Merge branch 'fixes' into for-next
Merge for-stable fixes branch into for-next development branch.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12 14:35:10 +01:00
Gustavo A. R. Silva
fc5a7f0339 power: supply: da9150-fg: remove VLA usage
In preparation to enabling -Wvla, remove VLA usage and replace it
with fixed-length arrays.

DA9150_QIF_LONG_SIZE (4 bytes) is the biggest size of an attribute which can
be accessed [1].

Fixed as part of the directive to remove all VLAs from
the kernel: https://lkml.org/lkml/2018/3/7/621

[1] https://marc.info/?l=kernel-hardening&m=152059600524753&w=2

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12 14:34:52 +01:00
Sebastian Reichel
90ad4cc203 power: supply: bq2415x: add DT referencing support
Add support for using bq2415x together with power_supply_am_i_supplied().

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12 14:34:51 +01:00
Sebastian Reichel
f72c14ad8c power: supply: bq27xxx: support missing supplier device
power_supply_am_i_supplied() can return negative error
codes. In this case we should assume, that no charger
is connected and the battery should be marked as
DISCHARGING instead of NOT_CHARGING.

Reported-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12 14:30:09 +01:00
Pierre Bourdon
66ec32fc7c max17042: propagate of_node to power supply device
max17042_get_status uses the core power_supply_am_i_supplied. That
function relies on DT properties to figure out the power supply
topology, and will error out without DT.

Fixes max17042 battery status being reported as "unknown".

Signed-off-by: Pierre Bourdon <delroth@google.com>
Signed-off-by: Andre Heider <a.heider@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-12 14:29:52 +01:00
Hans de Goede
f451655c72 power: supply: axp288_fuel_gauge: Fix full status reporting
Commit 2b5a4b4bf2 ("power: supply: axp288_fuel_gauge: Rework
get_status()"), switched from 0A current detection to using the capacity
register for full detection.

It turns out this fixes full reporting on some devices which keep trickle
charging long after the capacity register reach 100%, but breaks it on
some other devices where the charger stops charging before the capacity
register reaches 100%. This commit fixes this by also checking for
0A current when the reported capacity is above 90%.

Fixes: 2b5a4b4bf2 ("psy: axp288_fuel_gauge: Rework get_status()")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 18:02:20 +01:00
Carlo Caione
7638eb5666 power: supply: axp288_fuel_gauge: Do not register FG on ECS EF20EA
The ECS EF20EA laptop ships an AXP288 but it is actually using a
different, separate FG chip for AC and battery monitoring. On this
laptop we need to keep using the regular ACPI driver and disable the
AXP288 FG to avoid reporting two batteries to userspace.

Signed-off-by: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 17:21:11 +01:00
Moritz Fischer
d85b4f7b7f power: reset: gpio-poweroff: Support for timeout from device property
Add support for reading a timeout value from device property.
Fall back to previous default of 3s if nothing is specified.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2018-03-09 17:15:03 +01:00
Baolin Wang
3f5faf3a06 power: reset: Add Spreadtrum SC27xx PMIC power off support
On Spreadtrum platform, we need power off system through external SC27xx
series PMICs including the SC2720, SC2721, SC2723, SC2730 and SC2731 chips.
Thus this patch adds SC27xx series PMICs power-off support.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 17:11:31 +01:00
Quentin Schulz
6ff653e3e8 power: supply: axp20x_battery: add support for AXP813
The X-Powers AXP813 PMIC has got some slight differences from
AXP20X/AXP22X PMICs:
 - the maximum voltage supplied by the PMIC is 4.35 instead of 4.36/4.24
 for AXP20X/AXP22X,
 - the constant charge current formula is different,

It also has a bit to tell whether the battery percentage returned by the
PMIC is valid.

Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 16:52:33 +01:00
Quentin Schulz
648badd797 power: supply: axp20x_battery: use data struct for variant specific code
We used to use IDs to select a function or a feature depending on the
variant. It's easier to maintain the code by adding data structure
storing the few differences between variants so that we don't add a pile
of if conditions.

Let's use this data structure and update the code to use it.

Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
[updated POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN write property to use
the introduced set_max_voltage() callback]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 16:51:06 +01:00
Ladislav Michl
d47c1e4b2f power: supply: gpio-charger: Remove pdata from gpio_charger
Platform data are now used only during probe time, so remove
them from gpio_charger structure and consolidate probing
function accordingly.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
[Replace of_property_read_string with dev_property_read_string]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 16:50:28 +01:00
Ladislav Michl
f5fec4cc29 power: supply: gpio-charger: Use GPIOF_ACTIVE_LOW for legacy setup
Setting GPIOF_ACTIVE_LOW flag based on platform data gpio_active_low
makes return value of gpiod_get_value_cansleep directly usable.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 16:16:34 +01:00
Ladislav Michl
d433d04bb7 power: supply: gpio-charger: Remove redundant dev_err call in probe function
There is an error message within devm_kzalloc already.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-03-09 16:14:02 +01:00
Tony Lindgren
2ad1ec0d2f PM / AVS: SmartReflex: Prepare to use device tree based probing
We are currently probing smartreflex with omap_device while we are
already probing smartreflex related interconnect target module with
ti-sysc driver and dts data.

Before we can flip things on for ti-sysc, we need to prepare the
smartreflex driver a bit:

1. The smartreflex clock is really for the whole interconnect target
   module. So it may be configured at the parent device level with
   ti-sysc

2. With ti-sysc, we have the child device manage interconnect target
   module directly if pm_runtime_irq_safe() is set and there is only
   one child. In that case nobody else is going to call pm_runtime_get
   and put, so we need to add these calls to idle smartreflex properly
   after probe if not fully configured

3. With ti-sysc, the parent driver may rebind. So we want to use
   platform_driver_register() and don't want probe to be __init

Note that this patch depends on the related changes to ti-sysc driver
and omap_device probing to prevent both ti-sysc and omap_device to
try to probe smartreflex.

Cc: linux-pm@vger.kernel.org
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2018-02-28 16:32:09 -08:00
Linus Walleij
4a9be94055 power: gemini-poweroff: Avoid spurious poweroff
On the D-Link DIR-685 we get spurious poweroff from
infrared. Since that block (CIR) doesn't even have a
driver this can be safely ignored, we can revisit this
code once we have a device supporting CIR.

On the D-Link DNS-313 we get spurious poweroff from
the power button. This appears to be an initialization
issue: we need to enable the block (start the state
machine) before we clear any dangling IRQ.

This patch fixes both issues.

Fixes: f7a388d6cd ("power: reset: Add a driver for the Gemini poweroff")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-22 21:35:04 +01:00
Ladislav Michl
dde5953f05 power: supply: ltc2941-battery-gauge: Fix temperature units
Temperature is measured in tenths of degree Celsius.

Fixes: 085bc24d15 ("Add LTC2941/LTC2943 Battery Gauge Driver")
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-22 21:28:16 +01:00
Ognjen Galic
285995d15d power: add to_power_supply macro to the API
This patch adds the to_power_supply macro to upcast
a device to a power_supply struct.

This is needed because the same piece of code using
container_of is used in various other places, so we
abstract away such low-level operations via a macro.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ognjen Galic <smclt30p@gmail.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-02-21 23:27:13 +01:00
Ladislav Michl
416a1ae673 power: supply: gpio-charger: use helper variable to access device info
Using explicit struct device variable makes code a bit more readable.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-13 13:48:24 +01:00
Ladislav Michl
419cac572b power: supply: gpio-charger: Drop driver remove function
Simplify error unwinding using devm_* allocators. This also
makes driver remove function empty, so remove it.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-13 13:48:23 +01:00
Ladislav Michl
3bf4e03d19 power: supply: ltc2941-battery-gauge: Add charge empty and full properties
Add properties for charge empty and charge full thresholds.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-12 11:23:46 +01:00
Alexandre Belloni
6ab739bc1d power: reset: Add a driver for the Microsemi Ocelot reset
The Microsemi Ocelot SoC has a register allowing to reset the MIPS core.
Unfortunately, the syscon-reboot driver can't be used directly (but almost)
as the reset control may be disabled using another register.

Cc: linux-pm@vger.kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-02-12 11:23:46 +01:00
Linus Torvalds
972058ad79 power supply and reset changes for the v4.16 series
* bq27xxx: add bq27521 support
  * drop unused imx-snvs-poweroff driver
  * improve axp288 driver
  * misc. fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlpx13wACgkQ2O7X88g7
 +pp6QBAAlYcyFR1s/NrQA42zbMdFSHhzTzjQOoOXrik9ajRQNo5XuOyOYoS1LztW
 aaIzZm/GSgZ00wMNv/NoUkUU+CVhj2mhlIj/uintLmK8jryEcnLYAnrRiV38qkQQ
 JwQEet4IPhHQ4ljw6jexnhiieSLhl5HqufF1jDpV+b959sG0WyH1skeHbMM033c9
 giIgSn8lrgjG5of/bnoTIAnbsH+hummURQ7yox4Dqa+dqJ0oJK3U0uorbeyQtCuB
 57aPEiDfoxBBohkPcwpCCMOxkreShST2caNRrmyKHif3dj+80ZBIsHOme1rVaP0c
 XG5z3qu1lHkvxthLcNKEXAZ9+PD9kCKFIi3YUA8FLBwDyeYvJi+4uQ7VkzFXxK0H
 hYt4nYA5vO9i0rNaRdFPK/RYr6esTW9aVw3IASi9ic3oHncaW1Q/kpU7hglkND+w
 8MOPARgLR6G86D3FTsI8bxmkLuKr1k7Vae2MnhnX3jgPDKFF35yTh21LrLJQXDzX
 nQQ4YoLwdbU0dvhDc1vQMNc2t3wOwpZjfg5a8f2nd7xqFRM4uE4batN8MkefNkxv
 W0Dd+0H4n1Gy+Z9vvSmlwt1iGWWa9QqhNeLDrrtqpN43AJUfP3ucd4nFlDUNS921
 Ilt4e34OoXJoDNDsm00iCPduTtme7QChSnkiGY+cFiwA0CSgs3A=
 =XIx5
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - bq27xxx: add bq27521 support

 - drop unused imx-snvs-poweroff driver

 - improve axp288 driver

 - misc fixes

* tag 'for-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (32 commits)
  power: supply: max17042_battery: Always fall back to default platform-data
  power: supply: max17042_battery: Check battery current for status when supplied
  MAINTAINERS: Add AXP288 PMIC entry
  power: supply: axp288_fuel_gauge: Do not register our psy on (some) HDMI sticks
  power: supply: axp288_fuel_gauge: Optimize get_current()
  power: supply: axp288_fuel_gauge: Rework get_status()
  power: reset: account for const type of of_device_id.data
  power: supply: account for const type of of_device_id.data
  bq24190: Simplify code in property_is_writeable
  power: supply: axp288_fuel_gauge: Get iio-channels once during boot
  power: supply: axp288_charger: Properly stop work on probe-error / remove
  power: supply: axp288_charger: Simplify extcon cable handling
  power: supply: axp288_charger: Use the right property for the input current limit
  power: supply: axp288_charger: Pick lower input current limit not higher
  power: supply: axp288_charger: Do not cache input current limit value
  power: supply: axp288_charger: Remove no longer needed locking
  power: supply: axp288_charger: Use regmap_update_bits to set the input limits
  power: supply: axp288_charger: Cleanup some double empty lines
  power: supply: axp288_charger: Remove charger-enabled state tracking
  power: supply: axp288_charger: Add missing newlines to some messages
  ...
2018-01-31 12:55:31 -08:00
Hans de Goede
2d7e6a8376 power: supply: max17042_battery: Always fall back to default platform-data
It is possible to have CONFIG_OF enabled on x86 builds, where we have no
firmware provided max17042_platform_data. The CONFIG_OF implementation of
max17042_get_pdata would return NULL in this case, causing the probe to
fail.

Instead always fallback to the default platform-data, as used on x86 sofar,
when there is no firmware provided pdata, independent of CONFIG_OF.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-23 16:51:22 +01:00
Hans de Goede
6e5ab19d54 power: supply: max17042_battery: Check battery current for status when supplied
Even though the system is supplied, it may still be discharging if the
supply is e.g. only delivering 5V 0.5A. Check the avg battery current if
available for more accurate status reporting.

Cc: James <kernel@madingley.org>
Suggested-by: James <kernel@madingley.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-22 17:53:35 +01:00
Hans de Goede
b60c75b6a5 power: supply: axp288_fuel_gauge: Do not register our psy on (some) HDMI sticks
The Intel Compute Stick (Cherry Trail version) and the Meegopad T08 HDMI
stick, both use an axp288 PMIC.  They also both have this wired up in such
a way that the detection logic in the PMIC claims that a valid battery is
present, resuling in GNOME and KDE showing a full-battery in their status
bar and power-settings, while these devices do not have a battery.

For lack of a better fix add a DMI blacklist and do not register the
axp288_fuel_gauge psy on devices on the blacklist.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-09 17:50:05 +01:00
Hans de Goede
ceb40831c9 power: supply: axp288_fuel_gauge: Optimize get_current()
First check the discharge current, and when that is non 0 use that without
also checking the charge current (which will be 0 then). This makes
get_current() do only 1 i2c read instead of 2 when on battery.

This is esp. important given the pmic i2c bus mutex stuff used on boards
with an axp288 because the SoC's own punit also may access the axp288,
which makes i2c accesses more expensive then normal.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-09 17:45:08 +01:00
Hans de Goede
2b5a4b4bf2 power: supply: axp288_fuel_gauge: Rework get_status()
Relying on the (dis)charge current reporting for reporting FULL back to
userspace does not work really well and often leads to the reported status
getting stuck at e.g. 98/99% (the fuelgauge is not perfect) for hours.

What happens is that when the battery is full the axp288 keeps charging it
with a very low current. Until it is really really full and once really
really full, some inaccuracies in the adc lead to it then sometimes
reporting a small discharging rate, even though an external pwr source is
used. So we end up with a status of "charging" for hours after the battery
is actually already full and sometimes this then flip-flops to discharging.

This commit fixes this by first checking if a valid Vbus is present and if
it is present using the fuel-gauge's reported percentage to check for a
full battery.

This commit also changes how get_status() determines if the battery is
charging or discharging when not reporting it as full. We still use the
current direction for this, but instead of reading 4 extra registers for
this (2 16 bit regs), simplify things by using the current-direction bit
in the power-status register, which already gets read anyways.

This also reduces the amount of i2c reads to 1 when on battery and 2
when a valid Vbus is present.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-09 17:41:39 +01:00
Julia Lawall
8eb96f136f power: reset: account for const type of of_device_id.data
This driver creates a const structure that it stores in the data
field of an of_device_id array.

Add const to the declaration of the location that receives a value
from the data field to ensure that the compiler will continue to check
that the value is not modified and remove the const-dropping cast on
the access to the data field.

Done using Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:40:57 +01:00
Julia Lawall
a488ca6e70 power: supply: account for const type of of_device_id.data
This driver creates two const structures that it stores in the data
field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Furthermore, adding const to the declaration of the location that
receives a const value from such a field ensures that the compiler
will continue to check that the value is not modified.  The
const-discarding cast on the extraction from the data field is thus
no longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:40:46 +01:00
Pavel Machek
31381042a6 bq24190: Simplify code in property_is_writeable
Simplify function that should be trivial.

Signed-off-by: Pavel machek <pavel@ucw.cz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:40:06 +01:00
Hans de Goede
331645e165 power: supply: axp288_fuel_gauge: Get iio-channels once during boot
Get iio-channels once during boot, delaying the probe if the axp288_adc
drivers has not loaded yet, instead of getting them on demand each time
we need them.

This fixes the following errors in dmesg:

axp288_fuel_gauge axp288_fuel_gauge: ADC charge current read failed:-19

Which were caused by the ondemand iio-channel read code not finding the
channel when the axp288_adc driver had not loaded yet.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
165c235774 power: supply: axp288_charger: Properly stop work on probe-error / remove
Properly stop any work we may have queued on probe-errors / remove.

Rather then adding a remove driver callback for this, and goto style
error handling to probe, use a devm_action for this.

The devm_action gets registered before we register any of the extcon
notifiers which may queue the work, devm does cleanup in reverse order,
so this ensures that the notifiers are removed before we cancel the work.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
8c0a0a2959 power: supply: axp288_charger: Simplify extcon cable handling
Simplify extcon cable handling using the new
devm_extcon_register_notifier_all function to listen to all cables
in one go.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
81d56dd3d5 power: supply: axp288_charger: Use the right property for the input current limit
Use the right property for the input current limit and make it writable.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
9563d05416 power: supply: axp288_charger: Pick lower input current limit not higher
The code before this commit would pick 900 mA when asking for an input
current limit of 600mA, rather then 500 mA, not good.

While touching almost all code using the silly xxxMA defines anyways,
also get rid of these simply typing out the numbers and switch the
unit to uA as that is the psy class standard unit for currents.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
d1ce7e5853 power: supply: axp288_charger: Do not cache input current limit value
The hardware may change this underneath us.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
c28185bd3a power: supply: axp288_charger: Remove no longer needed locking
Now that we use regmap to do read-modify-write ops everywhere, we can
rely on the regmap lock and no longer need our own lock.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
bbafa111ca power: supply: axp288_charger: Use regmap_update_bits to set the input limits
Use regmap_update_bits in axp288_charger_set_vbus_inlmt, instead of DIY
code.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
a9904aa828 power: supply: axp288_charger: Cleanup some double empty lines
While we are doing cleanups, also remove some double blank lines.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
672b4b0060 power: supply: axp288_charger: Remove charger-enabled state tracking
The extcon code is the only one to trigger our worker (outside of the
initial run) and we can rely on it to only call us if things have
changed, so there is no need to track the charger-enabled state.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
a59943f8f6 power: supply: axp288_charger: Add missing newlines to some messages
Add missing (terminating) "\n"-s to some dev_dbg messages.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:57 +01:00
Hans de Goede
d8e6519535 power: supply: axp288_charger: Do not stop + restart charging at boot
Before this commit we were relying solely on the extcon interface for
cable detection, including to determine if a cable providing vbus is
connected at all. This caused us to turn off charging at boot, because
when we run the initial state processing the axp288-extcon driver is still
running charger-type detection most of the time, so all charger cable
types read as disconnected when we run the initial state processing.

This commit reworks the axp288_charger_extcon_evt_worker flow to use the
VBUS_VALID bit from the PWR_INPUT_STATUS register to determine if we
should turn charging on/off. Note this is the same bit as we use for the
online property.

If VBUS_VALID is set, but the extcon code has not completed the charger
type detection yet, we now simply bail leaving things as configured by
the BIOS (we will get a notifier call when the extcon code is done and
reschedule the axp288_charger_extcon_evt_worker).

The extcon code is the only one to trigger the worker (outside of the
initial run) and we can rely on it to only call us if things have changed,
so while we are completely refactoring axp288_charger_extcon_evt_worker,
also remove the code to check if the state has changed.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:38:56 +01:00
Dong Aisheng
baf61639b8 power: reset: remove unused imx-snvs-poweroff driver
There's no user of it in kernel now and it basically functions the same
as the generic syscon-poweroff.c to which we have already switched.
So let's remove it.

Cc: Robin Gong <yibin.gong@nxp.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:09:25 +01:00
Bjorn Andersson
fd8b8f17d8 power: reset: msm: Clarify restart and poweroff
When PSHOLD in a Qualcomm platform is deasserted the PMIC will perform
either a power off or a restart of the system. The action to take is
configured in the PON block, which is controlled by a separate driver.

As the configuration logic was added to the pm8941-pwrkey driver the
comment in do_msm_poweroff() is no longer valid and the name
do_msm_restart() is misleading. Update the naming and drop the comment.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-01-08 18:04:43 +01:00
Julia Lawall
5a2772a820 PM / AVS: rockchip-io: account for const type of of_device_id.data
This driver creates a number of const structures that it stores in the
data field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Furthermore, adding const to the declaration of the location that
receives a const value from such a field ensures that the compiler
will continue to check that the value is not modified.  The
const-discarding cast on the extraction from the data field is
thus no longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-01-05 13:36:33 +01:00
Pavel Machek
70a39e1075 Add support for bq27521 battery monitor
This adds basic support for BQ27521 battery monitor, used in Nokia N9
and N950. In particular, battery voltage is important to be able to
tell when the battery is almost empty. Emptying battery on N950 is
pretty painful, as flasher needs to be used to recover phone in such case.

Signed-off-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Andrew F. Davis <afd@ti.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-08 18:02:15 +01:00
Hans de Goede
d16002755d power: supply: bq24190_charger: Remove extcon handling
Now that drivers/i2c/busses/i2c-cht-wc.c uses
"input-current-limit-from-supplier" instead of "extcon-name" the last
user of the bq24190 extcon code is gone, remove it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:43:21 +01:00
Mike Looijmans
5f2f0d6105 power: ltc2941-battery-gauge: Disable continuous monitoring on shutdown
The driver sets the fuel gauge to continuous monitoring on startup, for
the models that support this. When the board shuts down, the chip remains
in that mode, causing a few mA drain on the battery every 2 or 10 seconds.

This patch registers a shutdown handler that turns off the monitoring to
prevent this battery drain.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:41:05 +01:00
Arvind Yadav
aac7990407 power: supply: cpcap-battery: Fix platform_get_irq_byname's error checking
The platform_get_irq_byname() function returns -1 if an error occurs.
zero or positive number on success. platform_get_irq_byname() error
checking for zero is not correct.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:22:10 +01:00
Christophe JAILLET
09edcb6475 power: supply: ab8500_charger: Bail out in case of error in 'ab8500_charger_init_hw_registers()'
If an error occurs when we enable the backup battery charging, we should
go through the error handling path directly.

Before commit db43e6c473 ("ab8500-bm: Add usb power path support") this
was the case, but this commit has added some code between the last test and
the 'out' label.
So, in case of error, this added code is executed and the error may be
silently ignored.

Fix it by adding the missing 'goto out', as done in all other error
handling paths.

Fixes: db43e6c473 ("ab8500-bm: Add usb power path support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:21:18 +01:00
Christophe JAILLET
bf59fddde1 power: supply: ab8500_charger: Fix an error handling path
'ret' is know to be 0 at this point, because it has not been updated by the
the previous call to 'abx500_mask_and_set_register_interruptible()'.

Fix it by updating 'ret' before checking if an error occurred.

Fixes: 84edbeeab6 ("ab8500-charger: AB8500 charger driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:21:18 +01:00
Ryosuke Saito
f46b151ede power: supply: charger-manager: Fix typo in condition
Should be discharging_max_duration_ms, not charging_max_duration_ms.

Signed-off-by: Ryosuke Saito <raitosyo@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:14:06 +01:00
Jesse Chan
348c7cf5fc power: reset: zx-reboot: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
This change resolves a new compile-time warning
when built as a loadable module:

WARNING: modpost: missing MODULE_LICENSE() in drivers/power/reset/zx-reboot.o
see include/linux/module.h for more information

This adds the license as "GPL v2", which matches the header of the file.

MODULE_DESCRIPTION and MODULE_AUTHOR are also added.

Signed-off-by: Jesse Chan <jc@linux.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:10:48 +01:00
Dan Carpenter
7d54d0d38e power: supply: sbs-message: double left shift bug in sbsm_select()
The original code does this: "1 << (1 << 11)" which is undefined in C.

Fixes: dbc4deda03 ("power: Adds support for Smart Battery System Manager")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-12-01 16:08:00 +01:00
Linus Torvalds
19b9aaf8a5 power supply and reset changes for the v4.15 series
* Misc. minor fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAloMMiIACgkQ2O7X88g7
 +po5Tg//cT+BUtyJuzHvBLt59OG7/qkMv5Kkazr6ZQIAD2gLp7aYQjLyqG82bnXI
 a/vEp0mXY6IWtmUmh0dk/sn8UUBFPyTxxAEKt1z/ygEf8/2Cozcji1QtEfqGpR2S
 5EDGneJ4aoLuBmNYEfOmw9ohr6uNhhhSZ46ev0k73pEPGZHU2BxRLDf8/hzuBRX/
 w8hMwF/5Mi5dREtjk0axauQwB7xCurxrHHPjaXDhPdYorLJ/xXcXUgc0fX6RvE9p
 ZIQEy5ESPsYdazSAW/Dtn0UgfFYuscWAh76lAxw3fQrlIbbVdy7rqrnUDJgh9qCP
 GW8vfK3IQi7oB4Y+H1Iyjl4e2tJKVPRugG8vfSQVWaVM2uVjD5dYTG/c9nPd968h
 7waPCpToPkP3Mv5MrXB049KNey06Jm8pMUmSzW2aMQhXHTwTBlubVpz2xCVbYYzM
 OJtOmv4D5i/qSO1cDvZUosF0yXnkCk0u9ZF9L0JAqznd7s0ZbJES6/Etjwo/TM2R
 RB5Ucu3nc8QXBhoH+AASPThkG7QmRDkzliaO9fIl18g4LiMAMYMmGB5bhTjc5Eog
 p7P3uVqMx8z9yqouX9+eJC6PbgiLm+oHesO6w4lxqFp/izeDvgQZrlRFqMAWxftU
 jLVSvkPjPD6JVdUG4cbkZfwyJ1doOS6djbmKC9Pi8kc01xV5nuY=
 =9LP+
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - misc minor fixes

* tag 'for-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  power: supply: cpcap-charger: fix incorrect return value check
  power: supply: replace pr_* with dev_*
  power: supply: pcf50633-charger: remove redundant variable charging_start
  power: supply: generic-adc-battery: remove redundant variable pdata
  power: supply: max8997: Improve a size determination in probe
2017-11-15 13:37:15 -08:00
Linus Torvalds
9682b3dea2 Merge branch 'for-linus' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
Pull trivial tree updates from Jiri Kosina:
 "The usual rocket-science from trivial tree for 4.15"

* 'for-linus' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jikos/trivial:
  MAINTAINERS: relinquish kconfig
  MAINTAINERS: Update my email address
  treewide: Fix typos in Kconfig
  kfifo: Fix comments
  init/Kconfig: Fix module signing document location
  misc: ibmasm: Return error on error path
  HID: logitech-hidpp: fix mistake in printk, "feeback" -> "feedback"
  MAINTAINERS: Correct path to uDraw PS3 driver
  tracing: Fix doc mistakes in trace sample
  tracing: Kconfig text fixes for CONFIG_HWLAT_TRACER
  MIPS: Alchemy: Remove reverted CONFIG_NETLINK_MMAP from db1xxx_defconfig
  mm/huge_memory.c: fixup grammar in comment
  lib/xz: Add fall-through comments to a switch statement
2017-11-15 10:14:11 -08:00
Linus Torvalds
4008e6a9bc Merge branch 'i2c/for-4.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:
 "This contains two bigger than usual tree-wide changes this time. They
  all have proper acks, caused no merge conflicts in linux-next where
  they have been for a while. They are namely:

   - to-gpiod conversion of the i2c-gpio driver and its users (touching
     arch/* and drivers/mfd/*)

   - adding a sbs-manager based on I2C core updates to SMBus alerts
     (touching drivers/power/*)

  Other notable changes:

   - i2c_boardinfo can now carry a dev_name to be used when the device
     is created. This is because some devices in ACPI world need fixed
     names to find the regulators.

   - the designware driver got a long discussed overhaul of its PM
     handling. img-scb and davinci got PM support, too.

   - at24 driver has way better OF support. And it has a new maintainer.
     Thanks Bartosz for stepping up!

  The rest is regular driver updates and fixes"

* 'i2c/for-4.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (55 commits)
  ARM: sa1100: simpad: Correct I2C GPIO offsets
  i2c: aspeed: Deassert reset in probe
  eeprom: at24: Add OF device ID table
  MAINTAINERS: new maintainer for AT24 driver
  i2c: nuc900: remove platform_data, too
  i2c: thunderx: Remove duplicate NULL check
  i2c: taos-evm: Remove duplicate NULL check
  i2c: Make i2c_unregister_device() NULL-aware
  i2c: xgene-slimpro: Support v2
  i2c: mpc: remove useless variable initialization
  i2c: omap: Trigger bus recovery in lockup case
  i2c: gpio: Add support for named gpios in DT
  dt-bindings: i2c: i2c-gpio: Add support for named gpios
  i2c: gpio: Local vars in probe
  i2c: gpio: Augment all boardfiles to use open drain
  i2c: gpio: Enforce open drain through gpiolib
  gpio: Make it possible for consumers to enforce open drain
  i2c: gpio: Convert to use descriptors
  power: supply: sbs-message: fix some code style issues
  power: supply: sbs-battery: remove unchecked return var
  ...
2017-11-14 17:52:21 -08:00
Linus Torvalds
894025f24b USB/PHY patches for 4.15-rc1
Here is the big set of USB and PHY driver updates for 4.15-rc1.
 
 There is the usual amount of gadget and xhci driver updates, along with
 phy and chipidea enhancements.  There's also a lot of SPDX tags and
 license boilerplate cleanups as well, which provide some churn in the
 diffstat.
 
 Other major thing is the typec code that moved out of staging and into
 the "real" part of the drivers/usb/ tree, which was nice to see happen.
 
 All of these have been in linux-next with no reported issues for a
 while.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWgm/Vw8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+yktXwCdGgpInfOEvOGFd83EPDL7a1ncyc4AoM5wI8yl
 1CeLipqVIN3IsMMJptvb
 =zvDI
 -----END PGP SIGNATURE-----

Merge tag 'usb-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB/PHY updates from Greg KH:
 "Here is the big set of USB and PHY driver updates for 4.15-rc1.

  There is the usual amount of gadget and xhci driver updates, along
  with phy and chipidea enhancements. There's also a lot of SPDX tags
  and license boilerplate cleanups as well, which provide some churn in
  the diffstat.

  Other major thing is the typec code that moved out of staging and into
  the "real" part of the drivers/usb/ tree, which was nice to see
  happen.

  All of these have been in linux-next with no reported issues for a
  while"

* tag 'usb-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (263 commits)
  usb: gadget: f_fs: Fix use-after-free in ffs_free_inst
  USB: usbfs: compute urb->actual_length for isochronous
  usb: core: message: remember to reset 'ret' to 0 when necessary
  USB: typec: Remove remaining redundant license text
  USB: typec: add SPDX identifiers to some files
  USB: renesas_usbhs: rcar?.h: add SPDX tags
  USB: chipidea: ci_hdrc_tegra.c: add SPDX line
  USB: host: xhci-debugfs: add SPDX lines
  USB: add SPDX identifiers to all remaining Makefiles
  usb: host: isp1362-hcd: remove a couple of redundant assignments
  USB: adutux: remove redundant variable minor
  usb: core: add a new usb_get_ptm_status() helper
  usb: core: add a 'type' parameter to usb_get_status()
  usb: core: introduce a new usb_get_std_status() helper
  usb: core: rename usb_get_status() 'type' argument to 'recip'
  usb: core: add Status Type definitions
  USB: gadget: Remove redundant license text
  USB: gadget: function: Remove redundant license text
  USB: gadget: udc: Remove redundant license text
  USB: gadget: legacy: Remove redundant license text
  ...
2017-11-13 21:14:07 -08:00
Pan Bian
838c8afa67 power: supply: cpcap-charger: fix incorrect return value check
Function platform_get_irq_byname() returns a negative error code on
failure, and a zero or positive number on success. However, in function
cpcap_usb_init_irq(), positive IRQ numbers are also taken as error
cases. Use "if (irq < 0)" instead of "if (!irq)" to validate the return
value of platform_get_irq_byname().

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-11-13 11:56:12 +01:00
Rafael J. Wysocki
040e8a4a4c Merge branches 'pm-pci', 'pm-avs' and 'pm-docs'
* pm-pci:
  PCI / PM: Add dev_dbg() to print device suspend power states
  PCI / PM: Do not resume any devices in pci_pm_prepare()

* pm-avs:
  PM / AVS: Use %pS printk format for direct addresses

* pm-docs:
  PM: docs: Fix formatting typo in devices.rst
2017-11-13 01:32:25 +01:00
Aishwarya Pant
33a7067732 power: supply: replace pr_* with dev_*
Use kernel preferred dev_* family of functions in place of pr_*,
wherever a device object is present.

Done with the help of coccinelle.

Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-11-06 13:59:41 +01:00
Colin Ian King
e7c984cc6f power: supply: pcf50633-charger: remove redundant variable charging_start
Variable charging_start is being set but is never read, it is therefore
redundant and can be removed. Cleans up sparse warning:

drivers/power/supply/pcf50633-charger.c:61:3: warning: Value stored to
'charging_start' is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-11-06 13:49:57 +01:00
Colin Ian King
393ce139d5 power: supply: generic-adc-battery: remove redundant variable pdata
Pointer pdata is assigned but never used, so remove it. Cleans up the
clang warning:

drivers/power/supply/generic-adc-battery.c:211:2: warning: Value
stored to 'pdata' is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-11-06 13:49:14 +01:00
Markus Elfring
c09c65ca5c power: supply: max8997: Improve a size determination in probe
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-11-06 13:49:12 +01:00
Paul Burton
fb615d61b5 Update MIPS email addresses
MIPS will soon not be a part of Imagination Technologies, and as such
many @imgtec.com email addresses will no longer be valid. This patch
updates the addresses for those who:

 - Have 10 or more patches in mainline authored using an @imgtec.com
   email address, or any patches dated within the past year.

 - Are still with Imagination but leaving as part of the MIPS business
   unit, as determined from an internal email address list.

 - Haven't already updated their email address (ie. JamesH) or expressed
   a desire to be excluded (ie. Maciej).

 - Acked v2 or earlier of this patch, which leaves Deng-Cheng, Matt &
   myself.

New addresses are of the form firstname.lastname@mips.com, and all
verified against an internal email address list.  An entry is added to
.mailmap for each person such that get_maintainer.pl will report the new
addresses rather than @imgtec.com addresses which will soon be dead.

Instances of the affected addresses throughout the tree are then
mechanically replaced with the new @mips.com address.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Cc: Deng-Cheng Zhu <dengcheng.zhu@mips.com>
Acked-by: Dengcheng Zhu <dengcheng.zhu@mips.com>
Cc: Matt Redfearn <matt.redfearn@imgtec.com>
Cc: Matt Redfearn <matt.redfearn@mips.com>
Acked-by: Matt Redfearn <matt.redfearn@mips.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: trivial@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-03 09:02:30 -07:00
Greg Kroah-Hartman
b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier.  The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.

This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.

How this work was done:

Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
 - file had no licensing information it it.
 - file was a */uapi/* one with no licensing information in it,
 - file was a */uapi/* one with existing licensing information,

Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.

The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne.  Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.

The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed.  Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.

Criteria used to select files for SPDX license identifier tagging was:
 - Files considered eligible had to be source code files.
 - Make and config files were included as candidates if they contained >5
   lines of source
 - File already had some variant of a license header in it (even if <5
   lines).

All documentation files were explicitly excluded.

The following heuristics were used to determine which SPDX license
identifiers to apply.

 - when both scanners couldn't find any license traces, file was
   considered to have no license information in it, and the top level
   COPYING file license applied.

   For non */uapi/* files that summary was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0                                              11139

   and resulted in the first patch in this series.

   If that file was a */uapi/* path one, it was "GPL-2.0 WITH
   Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0 WITH Linux-syscall-note                        930

   and resulted in the second patch in this series.

 - if a file had some form of licensing information in it, and was one
   of the */uapi/* ones, it was denoted with the Linux-syscall-note if
   any GPL family license was found in the file or had no licensing in
   it (per prior point).  Results summary:

   SPDX license identifier                            # files
   ---------------------------------------------------|------
   GPL-2.0 WITH Linux-syscall-note                       270
   GPL-2.0+ WITH Linux-syscall-note                      169
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
   LGPL-2.1+ WITH Linux-syscall-note                      15
   GPL-1.0+ WITH Linux-syscall-note                       14
   ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
   LGPL-2.0+ WITH Linux-syscall-note                       4
   LGPL-2.1 WITH Linux-syscall-note                        3
   ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
   ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1

   and that resulted in the third patch in this series.

 - when the two scanners agreed on the detected license(s), that became
   the concluded license(s).

 - when there was disagreement between the two scanners (one detected a
   license but the other didn't, or they both detected different
   licenses) a manual inspection of the file occurred.

 - In most cases a manual inspection of the information in the file
   resulted in a clear resolution of the license that should apply (and
   which scanner probably needed to revisit its heuristics).

 - When it was not immediately clear, the license identifier was
   confirmed with lawyers working with the Linux Foundation.

 - If there was any question as to the appropriate license identifier,
   the file was flagged for further research and to be revisited later
   in time.

In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.

Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights.  The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.

Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.

In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.

Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
 - a full scancode scan run, collecting the matched texts, detected
   license ids and scores
 - reviewing anything where there was a license detected (about 500+
   files) to ensure that the applied SPDX license was correct
 - reviewing anything where there was no detection but the patch license
   was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
   SPDX license was correct

This produced a worksheet with 20 files needing minor correction.  This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.

These .csv files were then reviewed by Greg.  Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected.  This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.)  Finally Greg ran the script using the .csv files to
generate the patches.

Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:10:55 +01:00
Wolfram Sang
4cf419a2b4 power: supply: sbs-message: fix some code style issues
Use 'unsigned int' and curly braces for 'else'.

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-10-29 00:50:44 +02:00
Wolfram Sang
5e9bee5267 power: supply: sbs-battery: remove unchecked return var
Since the return value is not checked anyhow, we don't need to store it.

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-10-29 00:45:59 +02:00
Wolfram Sang
9410b7d710 power: supply: sbs-battery: remove superfluous variable init
Those variables are immediately assigned a value afterwards.

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-10-29 00:42:10 +02:00
Phil Reid
1cf855535b power: supply: sbs-battery: move gpio present detect to sbs_get_property
Currently when a gpio is defined for battery presence it is only used in
the sbs_get_battery_presence_and_health function for 2 properties.
All other properties currently try to read data form the battery before
returning an error if not present. We should know in advance that no
data is going to returned.

As the driver tries multiple times to access a property, this prevents
a lot of smbus accesses, which had a significant effect on device boot-up.
As when the device is registered lots of property accesses are attempted
during boot.

If no gpio is used for presence detection no change in behaviour should
occur.

Signed-off-by: Phil Reid <preid@electromag.com.au>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-10-28 23:43:32 +02:00
Phil Reid
a0b8839e2a power: supply: sbs-manager: Add alert callback and battery change notification
This adds smb alert support via the smbus_alert driver to generate
power_supply_changed notifications when either external power is
removed / applied or a battery inserted / removed.
Use the i2c alert callback to notify the attached battery driver that a
change has occurred.

Signed-off-by: Phil Reid <preid@electromag.com.au>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-10-28 23:43:25 +02:00
Karl-Heinz Schneider
dbc4deda03 power: Adds support for Smart Battery System Manager
This patch adds support for Smart Battery System Manager.
A SBSM is a device listening at I2C/SMBus address 0x0a and is capable of
communicating up to four I2C smart battery devices. All smart battery
devices are listening at address 0x0b, so the SBSM muliplexes between
them. The driver makes use of the I2C-Mux framework to allow smart
batteries to be bound via device tree, i.e. the sbs-battery driver.

Via sysfs interface the online state and charge type are presented. If
the driver is bound as ltc1760 (an implementation of a Dual Smart Battery
System Manager) the charge type can also be changed from trickle to fast.

Signed-off-by: Karl-Heinz Schneider <karl-heinz@schneider-inet.de>
Signed-off-by: Phil Reid <preid@electromag.com.au>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2017-10-28 23:43:19 +02:00
Chanwoo Choi
176aa36012 extcon: Split out extcon header file for consumer and provider device
The extcon has two type of extcon devices as following.
- 'extcon provider deivce' adds new extcon device and detect the
   state/properties of external connector. Also, it notifies the
   state/properties to the extcon consumer device.
- 'extcon consumer device' gets the change state/properties
   from extcon provider device.
Prior to that, include/linux/extcon.h contains all exported API for
both provider and consumer device driver. To clarify the meaning of
header file and to remove the wrong use-case on consumer device,
this patch separates into extcon.h and extcon-provider.h.

[Description for include/linux/{extcon.h|extcon-provider.h}]
- extcon.h includes the extcon API and data structure for extcon consumer
  device driver. This header file contains the following APIs:
  : Register/unregister the notifier to catch the change of extcon device
  : Get the extcon device instance
  : Get the extcon device name
  : Get the state of each external connector
  : Get the property value of each external connector
  : Get the property capability of each external connector

- extcon-provider.h includes the extcon API and data structure for extcon
  provider device driver. This header file contains the following APIs:
  : Include 'include/linux/extcon.h'
  : Allocate the memory for extcon device instance
  : Register/unregister extcon device
  : Set the state of each external connector
  : Set the property value of each external connector
  : Set the property capability of each external connector

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
2017-10-23 14:07:58 +09:00
Masanari Iida
83fc61a563 treewide: Fix typos in Kconfig
This patch fixes some spelling typos found in Kconfig files.

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2017-10-12 15:42:00 +02:00
Helge Deller
e200052f82 PM / AVS: Use %pS printk format for direct addresses
Use the %pS instead of the %pF printk format specifier for printing
symbols from direct addresses. This is needed for the ia64, ppc64 and
parisc64 architectures.

Signed-off-by: Helge Deller <deller@gmx.de>
Acked-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-10-11 02:05:09 +02:00
Linus Torvalds
0ce5c79f38 power supply and reset changes for the v4.14 series
* New chip/feature support
  - bq27xxx: support updating battery config from DT
  - bq24190: support loading battery charge info from DT
  - LTC2941: add LTC2942/LTC2944 support
  - max17042: add ACPI support
  - max1721x: new driver
 * Misc
  - Move bq27xxx w1 driver from w1 into power-supply subsystem
  - Introduce power_supply_set_input_current_limit_from_supplier
  - constify stuff
  - some minor fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlmxSSQACgkQ2O7X88g7
 +ppf2xAAliDRdNPuxpKu69syiX+iNPaPHTqRXd41sAJlEX2IYv/avcoNFcGySplR
 gJYdlbx2Qd86aBaMf92h4tGihk2iNa87It9xkA+JgO3wNoKiZ+b5lk///IDk8aDF
 8sknSTXJtGYse0jwBRKTT4cL1ZW/g10heUxPr8AiX8nL4QhMf0TIxXawWQteAZDE
 dDz/UEAqbINooD5HtP716Z0e3U6FyWTqFc6UzuR+n8c6wC6n/JA6h91ASAHUmExT
 aH1JuQyrmucBp8cLhP01ThSkoIdGbcZM7nJ3WQBlfDricFJXa/yThug/mHvjztJX
 3U1UOZBqsb/LL9Dh5hl/D3+i+7qI29KCyUZiYUrwoiSjxM/AtOB2t4cAWmU7+PnJ
 V3coYC1s2DlwYcLIUiyE2zmVWIDcOuuOJhQjCdpUBTPvz83nQ0v5oXMn7VnQmWlO
 8Z/IRWnW90v2D2iHmSPAwFG3ATfH0pAP8G/4Wrudti+ymSxAhXaLqQcj3HHjKjvI
 3CEGOPAN9Opuof7SfkIVuoOjPzazx5GUpAZQKi8LS87KRdXN4ics3vbNB6VBDR50
 FzVhJJZBTeAOJCDogInuu4gDa0L5Ikfdkhqc+nvNfcdsE2k3H8Nb//+UPiPnfgEA
 mEFyp9gaY08/3ylDEHxp3N/W7POrL4QelTjv0dvdKW70i7KtWpA=
 =iy5f
 -----END PGP SIGNATURE-----

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

Pull power supply and reset changes from Sebastian Reichel:
 "New chip/feature support:
   - bq27xxx: support updating battery config from DT
   - bq24190: support loading battery charge info from DT
   - LTC2941: add LTC2942/LTC2944 support
   - max17042: add ACPI support
   - max1721x: new driver

  Misc:
   - Move bq27xxx w1 driver from w1 into power-supply subsystem
   - Introduce power_supply_set_input_current_limit_from_supplier
   - constify stuff
   - some minor fixes"

* tag 'for-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (39 commits)
  power: supply: bq27xxx: enable writing capacity values for bq27421
  power: supply: bq24190_charger: Get input_current_limit from our supplier
  power: supply: bq24190_charger: Export 5V boost converter as regulator
  power: supply: bq24190_charger: Add power_supply_battery_info support
  power: supply: bq24190_charger: Add property system-minimum-microvolt
  power: supply: bq24190_charger: Enable devicetree config
  dt-bindings: power: supply: Add docs for TI BQ24190 battery charger
  power: supply: bq27xxx: Remove duplicate chip data arrays
  power: supply: bq27xxx: Enable data memory update for certain chips
  power: supply: bq27xxx: Add chip IDs for previously shadowed chips
  power: supply: bq27xxx: Create single chip data table
  power: supply: bq24190_charger: Add ti,bq24192i to devicetree table
  power: supply: bq24190_charger: Add input_current_limit property
  power: supply: Add power_supply_set_input_current_limit_from_supplier helper
  power: supply: max17042_battery: Fix compiler warning
  power: supply: core: Delete two error messages for a failed memory allocation in power_supply_check_supplies()
  power: supply: make device_attribute const
  power: supply: max17042_battery: Fix ACPI interrupt issues
  power: supply: max17042_battery: Add support for ACPI enumeration
  power: supply: lp8788: Make several arrays static const * const
  ...
2017-09-09 14:44:39 -07:00
Linus Torvalds
968c61f7da - New Drivers
- RK805 Power Management IC (PMIC)
    - ROHM BD9571MWV-M MFD Power Management IC (PMIC)
    - Texas Instruments TPS68470 Power Management IC (PMIC) & LEDs
 
  - New Device Support
    - Add support for HiSilicon Hi6421v530 to hi6421-pmic-core
    - Add support for X-Powers AXP806 to axp20x
    - Add support for X-Powers AXP813 to axp20x
    - Add support for Intel Sunrise Point LPSS to intel-lpss-pci
 
  - New Functionality
    - Amend API to provide register layout; atmel-smc
 
 - Fix-ups
    - DT re-work; omap, nokia
    - Header file location change {I2C => MFD}; dm355evm_msp, tps65010
    - Fix chip ID formatting issue(s); rk808
    - Optionally register touchscreen devices; da9052-core
    - Documentation improvements; twl-core
    - Constification; rtsx_pcr, ab8500-core, da9055-i2c, da9052-spi
    - Drop unnecessary static declaration; max8925-i2c
    - Kconfig changes (missing deps and remove module support)
    - Slim down oversized licence statement; hi6421-pmic-core
    - Use managed resources (devm_*); lp87565
    - Supply proper error checking/handling; t7l66xb
 
  - Bug Fixes
    - Fix counter duplication issue; da9052-core
    - Fix potential NULL deference issue; max8998
    - Leave SPI-NOR write-protection bit alone; lpc_ich
    - Ensure device is put into reset during suspend; intel-lpss
    - Correct register offset variable size; omap-usb-tll
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCAAGBQJZsP0YAAoJEFGvii+H/HdhrJUP/RB6BTCDMf3WCi5e6PN8IFST
 JspCcf4bwKVc5lDvORQglVRfBhKY/uSr7F9xlfXtHx8V60ZNo1VOQcyJBTKIz+IJ
 +FQQgM3lEMKIn3QCcu9lKSRomJx55YDnF5SrZ8FzkC8pGLrCYEru5HfqFqOTfPqq
 OH2wZSqiX4H/jYdfVzp3bgqXkDff/nSEGTeFankFkv4wRvLGRxlpVuqkRJcvEJA3
 d8N9MoBBxkZAtAn2j1H5cHyPx5NrBEM2gkXpDfdd+kJNnFzjL72xsXd6rp+N6rcm
 d20eL+1fyJVyvGhGiDOhFwqRAZEqvjPSI4k5kQdRk8IdioGgbmaI74eUbv+rGAKp
 P9QdR7n1ctYyVgwnawIwKTPMzdZo5+9kdagCtu8IBVT02zQqVSDKZM7dAYo2rJuF
 yw24jONcwHFrKA25n1pLJmMbJGHq83kqqw3q5kl17nyArvOOcyspCTODIL9iskhZ
 L0IoIMwQYEj/pnI+iuXl9bJ30v2FIJxyCzUR2u7OJnrH7G27rsoOL0WDqxbp3Dp9
 7tD+6OzMiyIEDxtcd74kjg7g9p5HCmcY3FiDWirmQuZIR3abSET4ap+cTYPdFqVZ
 widS5Pi4PP40ZFN6+4lbBHLlh6MgpHpig9M03kFAr1SyZnH8nf4TnCsFV+wYPyTb
 LR3cKpFeTY8IyFWaLoSg
 =TKIm
 -----END PGP SIGNATURE-----

Merge tag 'mfd-next-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
 "New Drivers
   - RK805 Power Management IC (PMIC)
   - ROHM BD9571MWV-M MFD Power Management IC (PMIC)
   - Texas Instruments TPS68470 Power Management IC (PMIC) & LEDs

  New Device Support:
   - Add support for HiSilicon Hi6421v530 to hi6421-pmic-core
   - Add support for X-Powers AXP806 to axp20x
   - Add support for X-Powers AXP813 to axp20x
   - Add support for Intel Sunrise Point LPSS to intel-lpss-pci

  New Functionality:
   - Amend API to provide register layout; atmel-smc

  Fix-ups:
   - DT re-work; omap, nokia
   - Header file location change {I2C => MFD}; dm355evm_msp, tps65010
   - Fix chip ID formatting issue(s); rk808
   - Optionally register touchscreen devices; da9052-core
   - Documentation improvements; twl-core
   - Constification; rtsx_pcr, ab8500-core, da9055-i2c, da9052-spi
   - Drop unnecessary static declaration; max8925-i2c
   - Kconfig changes (missing deps and remove module support)
   - Slim down oversized licence statement; hi6421-pmic-core
   - Use managed resources (devm_*); lp87565
   - Supply proper error checking/handling; t7l66xb

  Bug Fixes:
   - Fix counter duplication issue; da9052-core
   - Fix potential NULL deference issue; max8998
   - Leave SPI-NOR write-protection bit alone; lpc_ich
   - Ensure device is put into reset during suspend; intel-lpss
   - Correct register offset variable size; omap-usb-tll"

* tag 'mfd-next-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (61 commits)
  mfd: intel_soc_pmic: Differentiate between Bay and Cherry Trail CRC variants
  mfd: intel_soc_pmic: Export separate mfd-cell configs for BYT and CHT
  dt-bindings: mfd: Add bindings for ZII RAVE devices
  mfd: omap-usb-tll: Fix register offsets
  mfd: da9052: Constify spi_device_id
  mfd: intel-lpss: Put I2C and SPI controllers into reset state on suspend
  mfd: da9055: Constify i2c_device_id
  mfd: intel-lpss: Add missing PCI ID for Intel Sunrise Point LPSS devices
  mfd: t7l66xb: Handle return value of clk_prepare_enable
  mfd: Add ROHM BD9571MWV-M PMIC DT bindings
  mfd: intel_soc_pmic_chtwc: Turn Kconfig option into a bool
  mfd: lp87565: Convert to use devm_mfd_add_devices()
  mfd: Add support for TPS68470 device
  mfd: lpc_ich: Do not touch SPI-NOR write protection bit on Haswell/Broadwell
  mfd: syscon: atmel-smc: Add helper to retrieve register layout
  mfd: axp20x: Use correct platform device ID for many PEK
  dt-bindings: mfd: axp20x: Introduce bindings for AXP813
  mfd: axp20x: Add support for AXP813 PMIC
  dt-bindings: mfd: axp20x: Add AXP806 to supported list of chips
  mfd: Add ROHM BD9571MWV-M MFD PMIC driver
  ...
2017-09-07 13:51:13 -07:00
Linus Torvalds
439644096c Power management updates for v4.14-rc1
- Drop the P-state selection algorithm based on a PID controller
    from intel_pstate and make it use the same P-state selection
    method (based on the CPU load) for all types of systems in the
    active mode (Rafael Wysocki, Srinivas Pandruvada).
 
  - Rework the cpufreq core and governors to make it possible to
    take cross-CPU utilization updates into account and modify the
    schedutil governor to actually do so (Viresh Kumar).
 
  - Clean up the handling of transition latency information in the
    cpufreq core and untangle it from the information on which drivers
    cannot do dynamic frequency switching (Viresh Kumar).
 
  - Add support for new SoCs (MT2701/MT7623 and MT7622) to the
    mediatek cpufreq driver and update its DT bindings (Sean Wang).
 
  - Modify the cpufreq dt-platdev driver to autimatically create
    cpufreq devices for the new (v2) Operating Performance Points
    (OPP) DT bindings and update its whitelist of supported systems
    (Viresh Kumar, Shubhrajyoti Datta, Marc Gonzalez, Khiem Nguyen,
    Finley Xiao).
 
  - Add support for Ux500 to the cpufreq-dt driver and drop the
    obsolete dbx500 cpufreq driver (Linus Walleij, Arnd Bergmann).
 
  - Add new SoC (R8A7795) support to the cpufreq rcar driver (Khiem
    Nguyen).
 
  - Fix and clean up assorted issues in the cpufreq drivers and core
    (Arvind Yadav, Christophe Jaillet, Colin Ian King, Gustavo Silva,
    Julia Lawall, Leonard Crestez, Rob Herring, Sudeep Holla).
 
  - Update the IO-wait boost handling in the schedutil governor to
    make it less aggressive (Joel Fernandes).
 
  - Rework system suspend diagnostics to make it print fewer messages
    to the kernel log by default, add a sysfs knob to allow more
    suspend-related messages to be printed and add Low Power S0 Idle
    constraints checks to the ACPI suspend-to-idle code (Rafael
    Wysocki, Srinivas Pandruvada).
 
  - Prefer suspend-to-idle over S3 on ACPI-based systems with the
    ACPI_FADT_LOW_POWER_S0 flag set and the Low Power Idle S0 _DSM
    interface present in the ACPI tables (Rafael Wysocki).
 
  - Update documentation related to system sleep and rename a number
    of items in the code to make it cleare that they are related to
    suspend-to-idle (Rafael Wysocki).
 
  - Export a variable allowing device drivers to check the target
    system sleep state from the core system suspend code (Florian
    Fainelli).
 
  - Clean up the cpuidle subsystem to handle the polling state on
    x86 in a more straightforward way and to use %pOF instead of
    full_name (Rafael Wysocki, Rob Herring).
 
  - Update the devfreq framework to fix and clean up a few minor
    issues (Chanwoo Choi, Rob Herring).
 
  - Extend diagnostics in the generic power domains (genpd) framework
    and clean it up slightly (Thara Gopinath, Rob Herring).
 
  - Fix and clean up a couple of issues in the operating performance
    points (OPP) framework (Viresh Kumar, Waldemar Rymarkiewicz).
 
  - Add support for RV1108 to the rockchip-io Adaptive Voltage Scaling
    (AVS) driver (David Wu).
 
  - Fix the usage of notifiers in CPU power management on some
    platforms (Alex Shi).
 
  - Update the pm-graph system suspend/hibernation and boot profiling
    utility (Todd Brandt).
 
  - Make it possible to run the cpupower utility without CPU0 (Prarit
    Bhargava).
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJZrcDJAAoJEILEb/54YlRx9FUQAIUKvWBAARc61ZIZXjbqZF1v
 aEMOBuksFns0CMekdptSic6n4wc81E/XYMS8yDhOOMpyDzfAZsTWjmu+gKwN7w3l
 E/yf/NVlhob9JZ7MqGgqD4EUFfFIaKBXPlWFdDi2rdCUXE2L8xJ7rla8i7zyZlc5
 pYHfAppBbF4qUcEY4OoOVOOGRZCfMdiLXj0iZOhMX8Y6yLBRk/AjnVADYsF33hoj
 gBEfomU+H0K5V8nQEp0ZFKDArPwL+oElHQj6i+nxBpGfPM5evvLXhHOyR6AsldJ5
 J4YI1kMuQNSCmvHMqOTxTYyJf8Jcf3Fj4wcjwaVMVGceY1lz6McAKknnFnCqCvz+
 mskn84gFCBCM8EoJDqRf0b9MQHcuRyQKM+yw4tjnR9r8yd32erb85ZWFHcPWYhCT
 fZatNOwFFv2MU+2vo5J3yeUNSWIKT+uBjy+tKPbrDkUwpKZVRj3Oj+hP3Mq9NE8U
 YBqltsj7tmrdA634zI8C7jfS6wF221S0fId/iPszwmPJaVn/lq8Ror7pWL5YI8U7
 SCJFjiqDiGmAcQEkuWwFAQnscZkyHpO+Y3A+jfXl/izoaZETaI5+ceIHBaocm3+5
 XrOOpHS3ik8EHf9ji0KFCKZ/pYDwllday3cBQPWo3sMIzpQ2lrjbqdnE1cVnBrld
 OtHZAeD/jLUXuY6XW2jN
 =mAiV
 -----END PGP SIGNATURE-----

Merge tag 'pm-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management updates from Rafael Wysocki:
 "This time (again) cpufreq gets the majority of changes which mostly
  are driver updates (including a major consolidation of intel_pstate),
  some schedutil governor modifications and core cleanups.

  There also are some changes in the system suspend area, mostly related
  to diagnostics and debug messages plus some renames of things related
  to suspend-to-idle. One major change here is that suspend-to-idle is
  now going to be preferred over S3 on systems where the ACPI tables
  indicate to do so and provide requsite support (the Low Power Idle S0
  _DSM in particular). The system sleep documentation and the tools
  related to it are updated too.

  The rest is a few cpuidle changes (nothing major), devfreq updates,
  generic power domains (genpd) framework updates and a few assorted
  modifications elsewhere.

  Specifics:

   - Drop the P-state selection algorithm based on a PID controller from
     intel_pstate and make it use the same P-state selection method
     (based on the CPU load) for all types of systems in the active mode
     (Rafael Wysocki, Srinivas Pandruvada).

   - Rework the cpufreq core and governors to make it possible to take
     cross-CPU utilization updates into account and modify the schedutil
     governor to actually do so (Viresh Kumar).

   - Clean up the handling of transition latency information in the
     cpufreq core and untangle it from the information on which drivers
     cannot do dynamic frequency switching (Viresh Kumar).

   - Add support for new SoCs (MT2701/MT7623 and MT7622) to the mediatek
     cpufreq driver and update its DT bindings (Sean Wang).

   - Modify the cpufreq dt-platdev driver to autimatically create
     cpufreq devices for the new (v2) Operating Performance Points (OPP)
     DT bindings and update its whitelist of supported systems (Viresh
     Kumar, Shubhrajyoti Datta, Marc Gonzalez, Khiem Nguyen, Finley
     Xiao).

   - Add support for Ux500 to the cpufreq-dt driver and drop the
     obsolete dbx500 cpufreq driver (Linus Walleij, Arnd Bergmann).

   - Add new SoC (R8A7795) support to the cpufreq rcar driver (Khiem
     Nguyen).

   - Fix and clean up assorted issues in the cpufreq drivers and core
     (Arvind Yadav, Christophe Jaillet, Colin Ian King, Gustavo Silva,
     Julia Lawall, Leonard Crestez, Rob Herring, Sudeep Holla).

   - Update the IO-wait boost handling in the schedutil governor to make
     it less aggressive (Joel Fernandes).

   - Rework system suspend diagnostics to make it print fewer messages
     to the kernel log by default, add a sysfs knob to allow more
     suspend-related messages to be printed and add Low Power S0 Idle
     constraints checks to the ACPI suspend-to-idle code (Rafael
     Wysocki, Srinivas Pandruvada).

   - Prefer suspend-to-idle over S3 on ACPI-based systems with the
     ACPI_FADT_LOW_POWER_S0 flag set and the Low Power Idle S0 _DSM
     interface present in the ACPI tables (Rafael Wysocki).

   - Update documentation related to system sleep and rename a number of
     items in the code to make it cleare that they are related to
     suspend-to-idle (Rafael Wysocki).

   - Export a variable allowing device drivers to check the target
     system sleep state from the core system suspend code (Florian
     Fainelli).

   - Clean up the cpuidle subsystem to handle the polling state on x86
     in a more straightforward way and to use %pOF instead of full_name
     (Rafael Wysocki, Rob Herring).

   - Update the devfreq framework to fix and clean up a few minor issues
     (Chanwoo Choi, Rob Herring).

   - Extend diagnostics in the generic power domains (genpd) framework
     and clean it up slightly (Thara Gopinath, Rob Herring).

   - Fix and clean up a couple of issues in the operating performance
     points (OPP) framework (Viresh Kumar, Waldemar Rymarkiewicz).

   - Add support for RV1108 to the rockchip-io Adaptive Voltage Scaling
     (AVS) driver (David Wu).

   - Fix the usage of notifiers in CPU power management on some
     platforms (Alex Shi).

   - Update the pm-graph system suspend/hibernation and boot profiling
     utility (Todd Brandt).

   - Make it possible to run the cpupower utility without CPU0 (Prarit
     Bhargava)"

* tag 'pm-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (87 commits)
  cpuidle: Make drivers initialize polling state
  cpuidle: Move polling state initialization code to separate file
  cpuidle: Eliminate the CPUIDLE_DRIVER_STATE_START symbol
  cpufreq: imx6q: Fix imx6sx low frequency support
  cpufreq: speedstep-lib: make several arrays static, makes code smaller
  PM: docs: Delete the obsolete states.txt document
  PM: docs: Describe high-level PM strategies and sleep states
  PM / devfreq: Fix memory leak when fail to register device
  PM / devfreq: Add dependency on PM_OPP
  PM / devfreq: Move private devfreq_update_stats() into devfreq
  PM / devfreq: Convert to using %pOF instead of full_name
  PM / AVS: rockchip-io: add io selectors and supplies for RV1108
  cpufreq: ti: Fix 'of_node_put' being called twice in error handling path
  cpufreq: dt-platdev: Drop few entries from whitelist
  cpufreq: dt-platdev: Automatically create cpufreq device with OPP v2
  ARM: ux500: don't select CPUFREQ_DT
  cpuidle: Convert to using %pOF instead of full_name
  cpufreq: Convert to using %pOF instead of full_name
  PM / Domains: Convert to using %pOF instead of full_name
  cpufreq: Cap the default transition delay value to 10 ms
  ...
2017-09-05 12:19:08 -07:00
Wolfram Sang
a205425658 mfd: twl: Move header file out of I2C realm
include/linux/i2c is not for client devices. Move the header file to a
more appropriate location.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-09-04 14:41:02 +01:00
H. Nikolaus Schaller
5d01fd38a3 power: supply: bq27xxx: enable writing capacity values for bq27421
Tested on Pyra prototype with bq27421.

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-31 10:25:24 +02:00
Hans de Goede
18f8e6f695 power: supply: bq24190_charger: Get input_current_limit from our supplier
On some devices the USB Type-C port power (USB PD 2.0) negotiation is
done by a separate port-controller IC, while the current limit is
controlled through another (charger) IC.

It has been decided to model this by modelling the external Type-C
power brick (adapter/charger) as a power-supply class device which
supplies the charger-IC, with its voltage-now and current-max representing
the negotiated voltage and max current draw.

This commit adds support for this to the bq24190_charger driver by adding
an external_power_changed callback and calling
power_supply_set_input_current_limit_from_supplier from this callback.
This callback will only get called if the bq24190 has a parent-supply.

Note this replaces the functionality to get the current-limit from an
extcon device, which will be removed in a follow-up commit.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-30 18:02:02 +02:00
Hans de Goede
66b6bef2c4 power: supply: bq24190_charger: Export 5V boost converter as regulator
Register the 5V boost converter as a regulator named "usb_otg_vbus".

This commit also adds support for bq24190_platform_data, through which
non device-tree platforms can pass the regulator_init_data (containing
mappings for the consumer amongst other things).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-30 17:31:51 +02:00
Liam Breck
14e1a131b5 power: supply: bq24190_charger: Add power_supply_battery_info support
Set pre-charge and charge-term current, obtained from power_supply_battery_info.
Add sysfs attributes precharge_current & charge_term_current.

Cc: Hans de Goede <hdegoede@redhat.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 23:08:39 +02:00
Liam Breck
8412a5bea7 power: supply: bq24190_charger: Add property system-minimum-microvolt
Set minimum system voltage limit obtained from device property.

Cc: Hans de Goede <hdegoede@redhat.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 23:08:39 +02:00
Liam Breck
a4c7590b8d power: supply: bq24190_charger: Enable devicetree config
Add get_config(). Rename set_mode_host() to set_config().
Call get_config() and hw_init() after power_supply_register().
No functional changes.

Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 23:08:38 +02:00
Liam Breck
1059361fb6 power: supply: bq27xxx: Remove duplicate chip data arrays
BQ2751X & BQ27510G3 have identical regs & props.
BQ2750X & BQ27510G3 have identical props.
BQ27500 & BQ27510G1 & BQ27510G2 have identical regs & props.
BQ27500 & BQ27520G2 have identical props.
Remove the duplicate arrays.

No functional changes to the driver.

Signed-off-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 23:08:38 +02:00
Liam Breck
05045379b2 power: supply: bq27xxx: Enable data memory update for certain chips
Support data memory update on BQ27425. Parameters from TI datasheets are also
provided for BQ27500, 545, 421, 441, 621; however these are commented out,
as they are not tested.

Add BQ27XXX_O_CFGUP & _O_RAM for use in bq27xxx_chip_data[n].opts
and by data memory update functions.

Signed-off-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 12:44:27 +02:00
Liam Breck
3a731c6414 power: supply: bq27xxx: Add chip IDs for previously shadowed chips
For the existing features, these chips act like others already ID'd,
so they had false but functional IDs. We will be adding features
which require correct IDs, so the following IDs are added:
BQ2752X, 531, 542, 546, 742, 425, 441, 621

Chip-specific features are now tracked by BQ27XXX_O_* flags in di->opts.

No functional changes to the driver.

Signed-off-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 12:37:35 +02:00
Liam Breck
9aade6d8f9 power: supply: bq27xxx: Create single chip data table
To support new features which require different data for each chip, we
unify the bq27xxx_regs and bq27xxx_battery_props tables into a single one.

No functional changes to the driver.

Signed-off-by: Liam Breck <kernel@networkimprov.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 12:30:34 +02:00
Liam Breck
64b46b7b87 power: supply: bq24190_charger: Add ti,bq24192i to devicetree table
bq24192i was previously only in ID table, so add it to DT table.

Cc: Tony Lindgren <tony@atomide.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 12:28:58 +02:00
Hans de Goede
74229f9384 power: supply: bq24190_charger: Add input_current_limit property
Export the input current limit of the charger as a
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT property on the charger
power_supply class device.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 12:26:59 +02:00
Hans de Goede
c3142dd8be power: supply: Add power_supply_set_input_current_limit_from_supplier helper
On some devices the USB Type-C port power (USB PD 2.0) negotiation is
done by a separate port-controller IC, while the current limit is
controlled through another (charger) IC.

It has been decided to model this by modelling the external Type-C
power brick (adapter/charger) as a power-supply class device which
supplies the charger-IC, with its voltage-now and current-max representing
the negotiated voltage and max current draw.

This commit adds a power_supply_set_input_current_limit_from_supplier
helper function which charger power-supply drivers can call to get
the max-current from their supplier and have this applied
through their set_property call-back to their input-current-limit.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 12:24:52 +02:00
Hans de Goede
4f1e0cb788 power: supply: max17042_battery: Fix compiler warning
Fix drivers/power/supply/max17042_battery.c:1059:6:
warning: 'acpi_id' may be used uninitialized in this function.

No idea why my gcc version did not catch this.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-29 12:04:14 +02:00
Markus Elfring
1e743997fb power: supply: core: Delete two error messages for a failed memory allocation in power_supply_check_supplies()
Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-28 18:50:39 +02:00
Bhumika Goyal
c023b90699 power: supply: make device_attribute const
Make these const as they are only passed as an argument to the
function device_create_file and device_remove_file and the corresponding
arguments are of type const.
Done using Coccinelle.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-28 18:48:44 +02:00
Hans de Goede
a865a15556 power: supply: max17042_battery: Fix ACPI interrupt issues
On some x86/ACPI boards the DSDT defines an ACPI event handler for
the max17047 IRQ, this causes several problems:

1) We need to share the IRQ to avoid an error getting it

2) Even of we are willing to share, we may fail to share because some
   DSDTs claim it exclusivly

3) If we are unable to share the IRQ, or the IRQ is only listed as an
   ACPI event source and not in the max1704 firmware node, then the
   charge threshold IRQ (which is used to give an IRQ every 1 percent
   charge change) becomes a problem, the ACPI event handler will not
   update this to the next 1 percent threshold, so the IRQ keeps firing
   and we get an IRQ storm pegging 1 CPU core.

   This happens despite the max17042 driver not setting the charge
   threshold because Windows uses it and leaves it set on reboot.

   So if we are unable to get the IRQ we need to reprogram the
   charge threshold to its disabled setting.

This commit fixes al of the above, while at it it also makes the error
msg when being unable to get the IRQ consistent with other messages.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-28 18:19:07 +02:00
Hans de Goede
e21162029a power: supply: max17042_battery: Add support for ACPI enumeration
Some x86 devices enumerate a max17047 fuel-gauge through a MAX17047
ACPI firmware-node, add support for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-28 18:19:07 +02:00
David Wu
9d913e4343 PM / AVS: rockchip-io: add io selectors and supplies for RV1108
This adds the necessary data for handling io voltage domains on the RV1108.

Signed-off-by: David Wu <david.wu@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-08-25 01:45:23 +02:00
Baolin Wang
626b6cd5f5 power: wm831x_power: Support USB charger current limit management
Integrate with the newly added USB charger interface to limit the current
we draw from the USB input based on the input device configuration
identified by the USB stack, allowing us to charge more quickly from high
current inputs without drawing more current than specified from others.

Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-08-15 15:05:01 +03:00
Colin Ian King
810e006a82 power: supply: lp8788: Make several arrays static const * const
Don't populate various read only arrays on the stack but make them
static const, making the object code smaller and saves 148 bytes
overall:

Before:
   text    data     bss     dec     hex filename
  11940    4496      64   16500    4074 lp8788-charger.o

After:
   text    data     bss     dec     hex filename
  11472    4816      64   16352    3fe0 lp8788-charger.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-12 13:58:14 -04:00
Christophe JAILLET
18a89d5c7c power: supply: charger-manager: Slighly simplify code
Use 'sizeof(*var)' instead of the equivalent 'sizeof(data structure type)'
because it is less verbose.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-11 18:54:35 +02:00
Christophe JAILLET
0299484e4d power: supply: charger-manager: Fix a comment
Update a comment which is no more up to date since commit
2ed9e9b653.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-11 18:53:59 +02:00
Christophe JAILLET
096fc160b7 power: supply: charger-manager: Fix a NULL pointer dereference in 'charger_manager_probe()'
'devm_kzalloc()' can return NULL. Return -ENOMEM in this case in order to
avoid a NULL pointer dereference later on.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-11 18:53:18 +02:00
Hans de Goede
46cecd130d power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate
Commit 2848e039c5 ("power: supply: Make power_supply_am_i_supplied return
-ENODEV if there are no suppliers") was supposed to make
power_supply_am_i_supplied() return -ENODEV when there are no supplies
which supply the supply passed to it.

But instead it will only return -ENODEV when there are no supplies at
all as data->count++; is incremented on every call of the iterator, rather
then only when __power_supply_is_supplied_by returns true. This commit
fixes this.

Fixes: 2848e039c5 ("power: supply: Make power_supply_am_i_supplied ...")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-08-09 17:56:46 +02:00