From 8c0984e5a75337df513047ec92a6c09d78e3e5cd Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 17 Jun 2016 13:54:32 +0200 Subject: [PATCH 01/46] power: move power supply drivers to power/supply This moves all power supply drivers from drivers/power/ to drivers/power/supply/. The intention is a cleaner source tree, since drivers/power/ also contains frameworks unrelated to power supply, like adaptive voltage scaling. Signed-off-by: Sebastian Reichel --- Documentation/power/power_supply_class.txt | 4 +- MAINTAINERS | 41 +- drivers/power/Kconfig | 518 +----------------- drivers/power/Makefile | 75 +-- drivers/power/{ => supply}/88pm860x_battery.c | 0 drivers/power/{ => supply}/88pm860x_charger.c | 0 drivers/power/supply/Kconfig | 514 +++++++++++++++++ drivers/power/supply/Makefile | 74 +++ drivers/power/{ => supply}/ab8500_bmdata.c | 0 drivers/power/{ => supply}/ab8500_btemp.c | 0 drivers/power/{ => supply}/ab8500_charger.c | 0 drivers/power/{ => supply}/ab8500_fg.c | 0 drivers/power/{ => supply}/abx500_chargalg.c | 0 drivers/power/{ => supply}/act8945a_charger.c | 0 drivers/power/{ => supply}/apm_power.c | 0 drivers/power/{ => supply}/axp20x_usb_power.c | 0 drivers/power/{ => supply}/axp288_charger.c | 0 .../power/{ => supply}/axp288_fuel_gauge.c | 0 drivers/power/{ => supply}/bq2415x_charger.c | 0 drivers/power/{ => supply}/bq24190_charger.c | 0 drivers/power/{ => supply}/bq24257_charger.c | 0 drivers/power/{ => supply}/bq24735-charger.c | 0 drivers/power/{ => supply}/bq25890_charger.c | 0 drivers/power/{ => supply}/bq27xxx_battery.c | 0 .../power/{ => supply}/bq27xxx_battery_i2c.c | 0 drivers/power/{ => supply}/charger-manager.c | 0 drivers/power/{ => supply}/collie_battery.c | 0 drivers/power/{ => supply}/da9030_battery.c | 0 drivers/power/{ => supply}/da9052-battery.c | 0 drivers/power/{ => supply}/da9150-charger.c | 0 drivers/power/{ => supply}/da9150-fg.c | 0 drivers/power/{ => supply}/ds2760_battery.c | 4 +- drivers/power/{ => supply}/ds2780_battery.c | 4 +- drivers/power/{ => supply}/ds2781_battery.c | 4 +- drivers/power/{ => supply}/ds2782_battery.c | 0 .../power/{ => supply}/generic-adc-battery.c | 0 drivers/power/{ => supply}/goldfish_battery.c | 0 drivers/power/{ => supply}/gpio-charger.c | 0 .../power/{ => supply}/intel_mid_battery.c | 0 .../power/{ => supply}/ipaq_micro_battery.c | 0 drivers/power/{ => supply}/isp1704_charger.c | 0 drivers/power/{ => supply}/jz4740-battery.c | 0 drivers/power/{ => supply}/lp8727_charger.c | 0 drivers/power/{ => supply}/lp8788-charger.c | 0 .../{ => supply}/ltc2941-battery-gauge.c | 0 drivers/power/{ => supply}/max14577_charger.c | 0 drivers/power/{ => supply}/max17040_battery.c | 0 drivers/power/{ => supply}/max17042_battery.c | 0 drivers/power/{ => supply}/max77693_charger.c | 0 drivers/power/{ => supply}/max8903_charger.c | 0 drivers/power/{ => supply}/max8925_power.c | 0 drivers/power/{ => supply}/max8997_charger.c | 0 drivers/power/{ => supply}/max8998_charger.c | 0 drivers/power/{ => supply}/olpc_battery.c | 0 drivers/power/{ => supply}/pcf50633-charger.c | 0 drivers/power/{ => supply}/pda_power.c | 0 drivers/power/{ => supply}/pm2301_charger.c | 0 drivers/power/{ => supply}/pm2301_charger.h | 0 drivers/power/{ => supply}/pmu_battery.c | 0 drivers/power/{ => supply}/power_supply.h | 0 .../power/{ => supply}/power_supply_core.c | 0 .../power/{ => supply}/power_supply_leds.c | 0 .../power/{ => supply}/power_supply_sysfs.c | 0 drivers/power/{ => supply}/qcom_smbb.c | 0 drivers/power/{ => supply}/rt5033_battery.c | 0 drivers/power/{ => supply}/rt9455_charger.c | 0 drivers/power/{ => supply}/rx51_battery.c | 0 drivers/power/{ => supply}/s3c_adc_battery.c | 0 drivers/power/{ => supply}/sbs-battery.c | 0 drivers/power/{ => supply}/smb347-charger.c | 0 drivers/power/{ => supply}/test_power.c | 0 drivers/power/{ => supply}/tosa_battery.c | 0 drivers/power/{ => supply}/tps65090-charger.c | 0 drivers/power/{ => supply}/tps65217_charger.c | 0 drivers/power/{ => supply}/twl4030_charger.c | 0 .../power/{ => supply}/twl4030_madc_battery.c | 0 drivers/power/{ => supply}/wm831x_backup.c | 0 drivers/power/{ => supply}/wm831x_power.c | 0 drivers/power/{ => supply}/wm8350_power.c | 0 drivers/power/{ => supply}/wm97xx_battery.c | 2 - drivers/power/{ => supply}/z2_battery.c | 0 81 files changed, 624 insertions(+), 616 deletions(-) rename drivers/power/{ => supply}/88pm860x_battery.c (100%) rename drivers/power/{ => supply}/88pm860x_charger.c (100%) create mode 100644 drivers/power/supply/Kconfig create mode 100644 drivers/power/supply/Makefile rename drivers/power/{ => supply}/ab8500_bmdata.c (100%) rename drivers/power/{ => supply}/ab8500_btemp.c (100%) rename drivers/power/{ => supply}/ab8500_charger.c (100%) rename drivers/power/{ => supply}/ab8500_fg.c (100%) rename drivers/power/{ => supply}/abx500_chargalg.c (100%) rename drivers/power/{ => supply}/act8945a_charger.c (100%) rename drivers/power/{ => supply}/apm_power.c (100%) rename drivers/power/{ => supply}/axp20x_usb_power.c (100%) rename drivers/power/{ => supply}/axp288_charger.c (100%) rename drivers/power/{ => supply}/axp288_fuel_gauge.c (100%) rename drivers/power/{ => supply}/bq2415x_charger.c (100%) rename drivers/power/{ => supply}/bq24190_charger.c (100%) rename drivers/power/{ => supply}/bq24257_charger.c (100%) rename drivers/power/{ => supply}/bq24735-charger.c (100%) rename drivers/power/{ => supply}/bq25890_charger.c (100%) rename drivers/power/{ => supply}/bq27xxx_battery.c (100%) rename drivers/power/{ => supply}/bq27xxx_battery_i2c.c (100%) rename drivers/power/{ => supply}/charger-manager.c (100%) rename drivers/power/{ => supply}/collie_battery.c (100%) rename drivers/power/{ => supply}/da9030_battery.c (100%) rename drivers/power/{ => supply}/da9052-battery.c (100%) rename drivers/power/{ => supply}/da9150-charger.c (100%) rename drivers/power/{ => supply}/da9150-fg.c (100%) rename drivers/power/{ => supply}/ds2760_battery.c (99%) rename drivers/power/{ => supply}/ds2780_battery.c (99%) rename drivers/power/{ => supply}/ds2781_battery.c (99%) rename drivers/power/{ => supply}/ds2782_battery.c (100%) rename drivers/power/{ => supply}/generic-adc-battery.c (100%) rename drivers/power/{ => supply}/goldfish_battery.c (100%) rename drivers/power/{ => supply}/gpio-charger.c (100%) rename drivers/power/{ => supply}/intel_mid_battery.c (100%) rename drivers/power/{ => supply}/ipaq_micro_battery.c (100%) rename drivers/power/{ => supply}/isp1704_charger.c (100%) rename drivers/power/{ => supply}/jz4740-battery.c (100%) rename drivers/power/{ => supply}/lp8727_charger.c (100%) rename drivers/power/{ => supply}/lp8788-charger.c (100%) rename drivers/power/{ => supply}/ltc2941-battery-gauge.c (100%) rename drivers/power/{ => supply}/max14577_charger.c (100%) rename drivers/power/{ => supply}/max17040_battery.c (100%) rename drivers/power/{ => supply}/max17042_battery.c (100%) rename drivers/power/{ => supply}/max77693_charger.c (100%) rename drivers/power/{ => supply}/max8903_charger.c (100%) rename drivers/power/{ => supply}/max8925_power.c (100%) rename drivers/power/{ => supply}/max8997_charger.c (100%) rename drivers/power/{ => supply}/max8998_charger.c (100%) rename drivers/power/{ => supply}/olpc_battery.c (100%) rename drivers/power/{ => supply}/pcf50633-charger.c (100%) rename drivers/power/{ => supply}/pda_power.c (100%) rename drivers/power/{ => supply}/pm2301_charger.c (100%) rename drivers/power/{ => supply}/pm2301_charger.h (100%) rename drivers/power/{ => supply}/pmu_battery.c (100%) rename drivers/power/{ => supply}/power_supply.h (100%) rename drivers/power/{ => supply}/power_supply_core.c (100%) rename drivers/power/{ => supply}/power_supply_leds.c (100%) rename drivers/power/{ => supply}/power_supply_sysfs.c (100%) rename drivers/power/{ => supply}/qcom_smbb.c (100%) rename drivers/power/{ => supply}/rt5033_battery.c (100%) rename drivers/power/{ => supply}/rt9455_charger.c (100%) rename drivers/power/{ => supply}/rx51_battery.c (100%) rename drivers/power/{ => supply}/s3c_adc_battery.c (100%) rename drivers/power/{ => supply}/sbs-battery.c (100%) rename drivers/power/{ => supply}/smb347-charger.c (100%) rename drivers/power/{ => supply}/test_power.c (100%) rename drivers/power/{ => supply}/tosa_battery.c (100%) rename drivers/power/{ => supply}/tps65090-charger.c (100%) rename drivers/power/{ => supply}/tps65217_charger.c (100%) rename drivers/power/{ => supply}/twl4030_charger.c (100%) rename drivers/power/{ => supply}/twl4030_madc_battery.c (100%) rename drivers/power/{ => supply}/wm831x_backup.c (100%) rename drivers/power/{ => supply}/wm831x_power.c (100%) rename drivers/power/{ => supply}/wm8350_power.c (100%) rename drivers/power/{ => supply}/wm97xx_battery.c (99%) rename drivers/power/{ => supply}/z2_battery.c (100%) diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt index 82dacc06e355..0c72588bd967 100644 --- a/Documentation/power/power_supply_class.txt +++ b/Documentation/power/power_supply_class.txt @@ -39,8 +39,8 @@ kind of power supply, and can process/present them to a user in consistent manner. Results for different power supplies and machines are also directly comparable. -See drivers/power/ds2760_battery.c and drivers/power/pda_power.c for the -example how to declare and handle attributes. +See drivers/power/supply/ds2760_battery.c and drivers/power/supply/pda_power.c +for the example how to declare and handle attributes. Units diff --git a/MAINTAINERS b/MAINTAINERS index 20bb1d00098c..ca66b4140c50 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3751,8 +3751,8 @@ F: drivers/leds/leds-da90??.c F: drivers/mfd/da903x.c F: drivers/mfd/da90??-*.c F: drivers/mfd/da91??-*.c -F: drivers/power/da9052-battery.c -F: drivers/power/da91??-*.c +F: drivers/power/supply/da9052-battery.c +F: drivers/power/supply/da91??-*.c F: drivers/regulator/da903x.c F: drivers/regulator/da9???-regulator.[ch] F: drivers/rtc/rtc-da90??.c @@ -7451,8 +7451,8 @@ MAXIM MUIC CHARGER DRIVERS FOR EXYNOS BASED BOARDS M: Krzysztof Kozlowski L: linux-pm@vger.kernel.org S: Supported -F: drivers/power/max14577_charger.c -F: drivers/power/max77693_charger.c +F: drivers/power/supply/max14577_charger.c +F: drivers/power/supply/max77693_charger.c MAXIM MAX77802 MULTIFUNCTION PMIC DEVICE DRIVERS M: Javier Martinez Canillas @@ -8323,11 +8323,11 @@ R: Pali Rohár F: include/linux/power/bq2415x_charger.h F: include/linux/power/bq27xxx_battery.h F: include/linux/power/isp1704_charger.h -F: drivers/power/bq2415x_charger.c -F: drivers/power/bq27xxx_battery.c -F: drivers/power/bq27xxx_battery_i2c.c -F: drivers/power/isp1704_charger.c -F: drivers/power/rx51_battery.c +F: drivers/power/supply/bq2415x_charger.c +F: drivers/power/supply/bq27xxx_battery.c +F: drivers/power/supply/bq27xxx_battery_i2c.c +F: drivers/power/supply/isp1704_charger.c +F: drivers/power/supply/rx51_battery.c NTB DRIVER CORE M: Jon Mason @@ -9334,8 +9334,7 @@ S: Maintained F: Documentation/devicetree/bindings/power/ F: Documentation/devicetree/bindings/power_supply/ F: include/linux/power_supply.h -F: drivers/power/ -X: drivers/power/avs/ +F: drivers/power/supply/ POWER STATE COORDINATION INTERFACE (PSCI) M: Mark Rutland @@ -10322,8 +10321,8 @@ F: drivers/thunderbolt/ TI BQ27XXX POWER SUPPLY DRIVER R: Andrew F. Davis F: include/linux/power/bq27xxx_battery.h -F: drivers/power/bq27xxx_battery.c -F: drivers/power/bq27xxx_battery_i2c.c +F: drivers/power/supply/bq27xxx_battery.c +F: drivers/power/supply/bq27xxx_battery_i2c.c TIMEKEEPING, CLOCKSOURCE CORE, NTP, ALARMTIMER M: John Stultz @@ -11329,6 +11328,16 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git S: Supported F: drivers/mfd/syscon.c +SYSTEM RESET/SHUTDOWN DRIVERS +M: Sebastian Reichel +M: Dmitry Eremin-Solenikov +M: David Woodhouse +L: linux-pm@vger.kernel.org +T: git git://git.infradead.org/battery-2.6.git +S: Maintained +F: Documentation/devicetree/bindings/power/reset/ +F: drivers/power/reset/ + SYSV FILESYSTEM M: Christoph Hellwig S: Maintained @@ -11677,7 +11686,7 @@ F: include/linux/platform_data/lp855x.h TI LP8727 CHARGER DRIVER M: Milo Kim S: Maintained -F: drivers/power/lp8727_charger.c +F: drivers/power/supply/lp8727_charger.c F: include/linux/platform_data/lp8727.h TI LP8788 MFD DRIVER @@ -11686,7 +11695,7 @@ S: Maintained F: drivers/iio/adc/lp8788_adc.c F: drivers/leds/leds-lp8788.c F: drivers/mfd/lp8788*.c -F: drivers/power/lp8788-charger.c +F: drivers/power/supply/lp8788-charger.c F: drivers/regulator/lp8788-*.c F: include/linux/mfd/lp8788*.h @@ -12762,7 +12771,7 @@ F: drivers/input/touchscreen/wm97*.c F: drivers/mfd/arizona* F: drivers/mfd/wm*.c F: drivers/mfd/cs47l24* -F: drivers/power/wm83*.c +F: drivers/power/supply/wm83*.c F: drivers/rtc/rtc-wm83*.c F: drivers/regulator/wm8*.c F: drivers/video/backlight/wm83*_bl.c diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index acd4a1524a1e..63454b5cac27 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -1,517 +1,3 @@ -menuconfig POWER_SUPPLY - bool "Power supply class support" - help - Say Y here to enable power supply class support. This allows - power supply (batteries, AC, USB) monitoring by userspace - via sysfs and uevent (if available) and/or APM kernel interface - (if selected below). - -if POWER_SUPPLY - -config POWER_SUPPLY_DEBUG - bool "Power supply debug" - help - Say Y here to enable debugging messages for power supply class - and drivers. - -config PDA_POWER - tristate "Generic PDA/phone power driver" - depends on !S390 - help - Say Y here to enable generic power driver for PDAs and phones with - one or two external power supplies (AC/USB) connected to main and - backup batteries, and optional builtin charger. - -config APM_POWER - tristate "APM emulation for class batteries" - depends on APM_EMULATION - help - Say Y here to enable support APM status emulation using - battery class devices. - -config GENERIC_ADC_BATTERY - tristate "Generic battery support using IIO" - depends on IIO - help - Say Y here to enable support for the generic battery driver - which uses IIO framework to read adc. - -config MAX8925_POWER - tristate "MAX8925 battery charger support" - depends on MFD_MAX8925 - help - Say Y here to enable support for the battery charger in the Maxim - MAX8925 PMIC. - -config WM831X_BACKUP - tristate "WM831X backup battery charger support" - depends on MFD_WM831X - help - Say Y here to enable support for the backup battery charger - in the Wolfson Microelectronics WM831x PMICs. - -config WM831X_POWER - tristate "WM831X PMU support" - depends on MFD_WM831X - help - Say Y here to enable support for the power management unit - provided by Wolfson Microelectronics WM831x PMICs. - -config WM8350_POWER - tristate "WM8350 PMU support" - depends on MFD_WM8350 - help - Say Y here to enable support for the power management unit - provided by the Wolfson Microelectronics WM8350 PMIC. - -config TEST_POWER - tristate "Test power driver" - help - This driver is used for testing. It's safe to say M here. - -config BATTERY_88PM860X - tristate "Marvell 88PM860x battery driver" - depends on MFD_88PM860X - help - Say Y here to enable battery monitor for Marvell 88PM860x chip. - -config BATTERY_ACT8945A - tristate "Active-semi ACT8945A charger driver" - depends on MFD_ACT8945A || COMPILE_TEST - help - Say Y here to enable support for power supply provided by - Active-semi ActivePath ACT8945A charger. - -config BATTERY_DS2760 - tristate "DS2760 battery driver (HP iPAQ & others)" - depends on W1 && W1_SLAVE_DS2760 - help - Say Y here to enable support for batteries with ds2760 chip. - -config BATTERY_DS2780 - tristate "DS2780 battery driver" - depends on HAS_IOMEM - select W1 - select W1_SLAVE_DS2780 - help - Say Y here to enable support for batteries with ds2780 chip. - -config BATTERY_DS2781 - tristate "DS2781 battery driver" - depends on HAS_IOMEM - select W1 - select W1_SLAVE_DS2781 - help - If you enable this you will have the DS2781 battery driver support. - - The battery monitor chip is used in many batteries/devices - as the one who is responsible for charging/discharging/monitoring - Li+ batteries. - - If you are unsure, say N. - -config BATTERY_DS2782 - tristate "DS2782/DS2786 standalone gas-gauge" - depends on I2C - help - Say Y here to enable support for the DS2782/DS2786 standalone battery - gas-gauge. - -config BATTERY_PMU - tristate "Apple PMU battery" - depends on PPC32 && ADB_PMU - help - Say Y here to expose battery information on Apple machines - through the generic battery class. - -config BATTERY_OLPC - tristate "One Laptop Per Child battery" - depends on X86_32 && OLPC - help - Say Y to enable support for the battery on the OLPC laptop. - -config BATTERY_TOSA - tristate "Sharp SL-6000 (tosa) battery" - depends on MACH_TOSA && MFD_TC6393XB && TOUCHSCREEN_WM97XX - help - Say Y to enable support for the battery on the Sharp Zaurus - SL-6000 (tosa) models. - -config BATTERY_COLLIE - tristate "Sharp SL-5500 (collie) battery" - depends on SA1100_COLLIE && MCP_UCB1200 - help - Say Y to enable support for the battery on the Sharp Zaurus - SL-5500 (collie) models. - -config BATTERY_IPAQ_MICRO - tristate "iPAQ Atmel Micro ASIC battery driver" - depends on MFD_IPAQ_MICRO - help - Choose this option if you want to monitor battery status on - Compaq/HP iPAQ h3100 and h3600. - -config BATTERY_WM97XX - bool "WM97xx generic battery driver" - depends on TOUCHSCREEN_WM97XX=y - help - Say Y to enable support for battery measured by WM97xx aux port. - -config BATTERY_SBS - tristate "SBS Compliant gas gauge" - depends on I2C - help - Say Y to include support for SBS battery driver for SBS-compliant - gas gauges. - -config BATTERY_BQ27XXX - tristate "BQ27xxx battery driver" - help - Say Y here to enable support for batteries with BQ27xxx chips. - -config BATTERY_BQ27XXX_I2C - tristate "BQ27xxx I2C support" - depends on BATTERY_BQ27XXX - depends on I2C - default y - help - Say Y here to enable support for batteries with BQ27xxx chips - connected over an I2C bus. - -config BATTERY_DA9030 - tristate "DA9030 battery driver" - depends on PMIC_DA903X - help - Say Y here to enable support for batteries charger integrated into - DA9030 PMIC. - -config BATTERY_DA9052 - tristate "Dialog DA9052 Battery" - depends on PMIC_DA9052 - help - Say Y here to enable support for batteries charger integrated into - DA9052 PMIC. - -config CHARGER_DA9150 - tristate "Dialog Semiconductor DA9150 Charger support" - depends on MFD_DA9150 - depends on DA9150_GPADC - depends on IIO - help - Say Y here to enable support for charger unit of the DA9150 - Integrated Charger & Fuel-Gauge IC. - - This driver can also be built as a module. If so, the module will be - called da9150-charger. - -config BATTERY_DA9150 - tristate "Dialog Semiconductor DA9150 Fuel Gauge support" - depends on MFD_DA9150 - help - Say Y here to enable support for the Fuel-Gauge unit of the DA9150 - Integrated Charger & Fuel-Gauge IC - - This driver can also be built as a module. If so, the module will be - called da9150-fg. - -config AXP288_CHARGER - tristate "X-Powers AXP288 Charger" - depends on MFD_AXP20X && EXTCON_AXP288 - help - Say yes here to have support X-Power AXP288 power management IC (PMIC) - integrated charger. - -config AXP288_FUEL_GAUGE - tristate "X-Powers AXP288 Fuel Gauge" - depends on MFD_AXP20X && IIO - help - Say yes here to have support for X-Power power management IC (PMIC) - Fuel Gauge. The device provides battery statistics and status - monitoring as well as alerts for battery over/under voltage and - over/under temperature. - -config BATTERY_MAX17040 - tristate "Maxim MAX17040 Fuel Gauge" - depends on I2C - help - MAX17040 is fuel-gauge systems for lithium-ion (Li+) batteries - in handheld and portable equipment. The MAX17040 is configured - to operate with a single lithium cell - -config BATTERY_MAX17042 - tristate "Maxim MAX17042/17047/17050/8997/8966 Fuel Gauge" - depends on I2C - select REGMAP_I2C - help - MAX17042 is fuel-gauge systems for lithium-ion (Li+) batteries - in handheld and portable equipment. The MAX17042 is configured - to operate with a single lithium cell. MAX8997 and MAX8966 are - multi-function devices that include fuel gauages that are compatible - with MAX17042. This driver also supports max17047/50 chips which are - improved version of max17042. - -config BATTERY_Z2 - tristate "Z2 battery driver" - depends on I2C && MACH_ZIPIT2 - help - Say Y to include support for the battery on the Zipit Z2. - -config BATTERY_S3C_ADC - tristate "Battery driver for Samsung ADC based monitoring" - depends on S3C_ADC - help - Say Y here to enable support for iPAQ h1930/h1940/rx1950 battery - -config BATTERY_TWL4030_MADC - tristate "TWL4030 MADC battery driver" - depends on TWL4030_MADC - help - Say Y here to enable this dumb driver for batteries managed - through the TWL4030 MADC. - -config CHARGER_88PM860X - tristate "Marvell 88PM860x Charger driver" - depends on MFD_88PM860X && BATTERY_88PM860X - help - Say Y here to enable charger for Marvell 88PM860x chip. - -config CHARGER_PCF50633 - tristate "NXP PCF50633 MBC" - depends on MFD_PCF50633 - help - Say Y to include support for NXP PCF50633 Main Battery Charger. - -config BATTERY_JZ4740 - tristate "Ingenic JZ4740 battery" - depends on MACH_JZ4740 - depends on MFD_JZ4740_ADC - help - Say Y to enable support for the battery on Ingenic JZ4740 based - boards. - - This driver can be build as a module. If so, the module will be - called jz4740-battery. - -config BATTERY_INTEL_MID - tristate "Battery driver for Intel MID platforms" - depends on INTEL_SCU_IPC && SPI - help - Say Y here to enable the battery driver on Intel MID - platforms. - -config BATTERY_RX51 - tristate "Nokia RX-51 (N900) battery driver" - depends on TWL4030_MADC - help - Say Y here to enable support for battery information on Nokia - RX-51, also known as N900 tablet. - -config CHARGER_ISP1704 - tristate "ISP1704 USB Charger Detection" - depends on USB_PHY - depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't be 'y' - help - Say Y to enable support for USB Charger Detection with - ISP1707/ISP1704 USB transceivers. - -config CHARGER_MAX8903 - tristate "MAX8903 Battery DC-DC Charger for USB and Adapter Power" - help - Say Y to enable support for the MAX8903 DC-DC charger and sysfs. - The driver supports controlling charger-enable and current-limit - pins based on the status of charger connections with interrupt - handlers. - -config CHARGER_TWL4030 - tristate "OMAP TWL4030 BCI charger driver" - depends on IIO && TWL4030_CORE - help - Say Y here to enable support for TWL4030 Battery Charge Interface. - -config CHARGER_LP8727 - tristate "TI/National Semiconductor LP8727 charger driver" - depends on I2C - help - Say Y here to enable support for LP8727 Charger Driver. - -config CHARGER_LP8788 - tristate "TI LP8788 charger driver" - depends on MFD_LP8788 - depends on LP8788_ADC - depends on IIO - help - Say Y to enable support for the LP8788 linear charger. - -config CHARGER_GPIO - tristate "GPIO charger" - depends on GPIOLIB || COMPILE_TEST - help - Say Y to include support for chargers which report their online status - through a GPIO pin. - - This driver can be build as a module. If so, the module will be - called gpio-charger. - -config CHARGER_MANAGER - bool "Battery charger manager for multiple chargers" - depends on REGULATOR - select EXTCON - help - Say Y to enable charger-manager support, which allows multiple - chargers attached to a battery and multiple batteries attached to a - system. The charger-manager also can monitor charging status in - runtime and in suspend-to-RAM by waking up the system periodically - with help of suspend_again support. - -config CHARGER_MAX14577 - tristate "Maxim MAX14577/77836 battery charger driver" - depends on MFD_MAX14577 - help - Say Y to enable support for the battery charger control sysfs and - platform data of MAX14577/77836 MUICs. - -config CHARGER_MAX77693 - tristate "Maxim MAX77693 battery charger driver" - depends on MFD_MAX77693 - help - Say Y to enable support for the Maxim MAX77693 battery charger. - -config CHARGER_MAX8997 - tristate "Maxim MAX8997/MAX8966 PMIC battery charger driver" - depends on MFD_MAX8997 && REGULATOR_MAX8997 - help - Say Y to enable support for the battery charger control sysfs and - platform data of MAX8997/LP3974 PMICs. - -config CHARGER_MAX8998 - tristate "Maxim MAX8998/LP3974 PMIC battery charger driver" - depends on MFD_MAX8998 && REGULATOR_MAX8998 - help - Say Y to enable support for the battery charger control sysfs and - platform data of MAX8998/LP3974 PMICs. - -config CHARGER_QCOM_SMBB - tristate "Qualcomm Switch-Mode Battery Charger and Boost" - depends on MFD_SPMI_PMIC || COMPILE_TEST - depends on OF - depends on EXTCON - help - Say Y to include support for the Switch-Mode Battery Charger and - Boost (SMBB) hardware found in Qualcomm PM8941 PMICs. The charger - is an integrated, single-cell lithium-ion battery charger. DT - configuration is required for loading, see the devicetree - documentation for more detail. The base name for this driver is - 'pm8941_charger'. - -config CHARGER_BQ2415X - tristate "TI BQ2415x battery charger driver" - depends on I2C - help - Say Y to enable support for the TI BQ2415x battery charger - PMICs. - - You'll need this driver to charge batteries on e.g. Nokia - RX-51/N900. - -config CHARGER_BQ24190 - tristate "TI BQ24190 battery charger driver" - depends on I2C - depends on GPIOLIB || COMPILE_TEST - help - Say Y to enable support for the TI BQ24190 battery charger. - -config CHARGER_BQ24257 - tristate "TI BQ24250/24251/24257 battery charger driver" - depends on I2C - depends on GPIOLIB || COMPILE_TEST - depends on REGMAP_I2C - help - Say Y to enable support for the TI BQ24250, BQ24251, and BQ24257 battery - chargers. - -config CHARGER_BQ24735 - tristate "TI BQ24735 battery charger support" - depends on I2C - depends on GPIOLIB || COMPILE_TEST - help - Say Y to enable support for the TI BQ24735 battery charger. - -config CHARGER_BQ25890 - tristate "TI BQ25890 battery charger driver" - depends on I2C - depends on GPIOLIB || COMPILE_TEST - select REGMAP_I2C - help - Say Y to enable support for the TI BQ25890 battery charger. - -config CHARGER_SMB347 - tristate "Summit Microelectronics SMB347 Battery Charger" - depends on I2C - select REGMAP_I2C - help - Say Y to include support for Summit Microelectronics SMB347 - Battery Charger. - -config CHARGER_TPS65090 - tristate "TPS65090 battery charger driver" - depends on MFD_TPS65090 - help - Say Y here to enable support for battery charging with TPS65090 - PMIC chips. - -config CHARGER_TPS65217 - tristate "TPS65217 battery charger driver" - depends on MFD_TPS65217 - help - Say Y here to enable support for battery charging with TPS65217 - PMIC chips. - -config BATTERY_GAUGE_LTC2941 - tristate "LTC2941/LTC2943 Battery Gauge Driver" - depends on I2C - help - Say Y here to include support for LTC2941 and LTC2943 Battery - Gauge IC. The driver reports the charge count continuously, and - measures the voltage and temperature every 10 seconds. - -config AB8500_BM - bool "AB8500 Battery Management Driver" - depends on AB8500_CORE && AB8500_GPADC - help - Say Y to include support for AB8500 battery management. - -config BATTERY_GOLDFISH - tristate "Goldfish battery driver" - depends on GOLDFISH || COMPILE_TEST - depends on HAS_IOMEM - help - Say Y to enable support for the battery and AC power in the - Goldfish emulator. - -config BATTERY_RT5033 - tristate "RT5033 fuel gauge support" - depends on MFD_RT5033 - help - This adds support for battery fuel gauge in Richtek RT5033 PMIC. - The fuelgauge calculates and determines the battery state of charge - according to battery open circuit voltage. - -config CHARGER_RT9455 - tristate "Richtek RT9455 battery charger driver" - depends on I2C - depends on GPIOLIB || COMPILE_TEST - select REGMAP_I2C - help - Say Y to enable support for Richtek RT9455 battery charger. - -config AXP20X_POWER - tristate "AXP20x power supply driver" - depends on MFD_AXP20X - help - This driver provides support for the power supply features of - AXP20x PMIC. - -endif # POWER_SUPPLY - -source "drivers/power/reset/Kconfig" source "drivers/power/avs/Kconfig" +source "drivers/power/reset/Kconfig" +source "drivers/power/supply/Kconfig" diff --git a/drivers/power/Makefile b/drivers/power/Makefile index e46b75d448a5..ff35c712d824 100644 --- a/drivers/power/Makefile +++ b/drivers/power/Makefile @@ -1,76 +1,3 @@ -subdir-ccflags-$(CONFIG_POWER_SUPPLY_DEBUG) := -DDEBUG - -power_supply-y := power_supply_core.o -power_supply-$(CONFIG_SYSFS) += power_supply_sysfs.o -power_supply-$(CONFIG_LEDS_TRIGGERS) += power_supply_leds.o - -obj-$(CONFIG_POWER_SUPPLY) += power_supply.o -obj-$(CONFIG_GENERIC_ADC_BATTERY) += generic-adc-battery.o - -obj-$(CONFIG_PDA_POWER) += pda_power.o -obj-$(CONFIG_APM_POWER) += apm_power.o -obj-$(CONFIG_AXP20X_POWER) += axp20x_usb_power.o -obj-$(CONFIG_MAX8925_POWER) += max8925_power.o -obj-$(CONFIG_WM831X_BACKUP) += wm831x_backup.o -obj-$(CONFIG_WM831X_POWER) += wm831x_power.o -obj-$(CONFIG_WM8350_POWER) += wm8350_power.o -obj-$(CONFIG_TEST_POWER) += test_power.o - -obj-$(CONFIG_BATTERY_88PM860X) += 88pm860x_battery.o -obj-$(CONFIG_BATTERY_ACT8945A) += act8945a_charger.o -obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o -obj-$(CONFIG_BATTERY_DS2780) += ds2780_battery.o -obj-$(CONFIG_BATTERY_DS2781) += ds2781_battery.o -obj-$(CONFIG_BATTERY_DS2782) += ds2782_battery.o -obj-$(CONFIG_BATTERY_GAUGE_LTC2941) += ltc2941-battery-gauge.o -obj-$(CONFIG_BATTERY_GOLDFISH) += goldfish_battery.o -obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o -obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o -obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o -obj-$(CONFIG_BATTERY_COLLIE) += collie_battery.o -obj-$(CONFIG_BATTERY_IPAQ_MICRO) += ipaq_micro_battery.o -obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o -obj-$(CONFIG_BATTERY_SBS) += sbs-battery.o -obj-$(CONFIG_BATTERY_BQ27XXX) += bq27xxx_battery.o -obj-$(CONFIG_BATTERY_BQ27XXX_I2C) += bq27xxx_battery_i2c.o -obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o -obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o -obj-$(CONFIG_CHARGER_DA9150) += da9150-charger.o -obj-$(CONFIG_BATTERY_DA9150) += da9150-fg.o -obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o -obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o -obj-$(CONFIG_BATTERY_Z2) += z2_battery.o -obj-$(CONFIG_BATTERY_RT5033) += rt5033_battery.o -obj-$(CONFIG_CHARGER_RT9455) += rt9455_charger.o -obj-$(CONFIG_BATTERY_S3C_ADC) += s3c_adc_battery.o -obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o -obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o -obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o -obj-$(CONFIG_BATTERY_JZ4740) += jz4740-battery.o -obj-$(CONFIG_BATTERY_INTEL_MID) += intel_mid_battery.o -obj-$(CONFIG_BATTERY_RX51) += rx51_battery.o -obj-$(CONFIG_AB8500_BM) += ab8500_bmdata.o ab8500_charger.o ab8500_fg.o ab8500_btemp.o abx500_chargalg.o pm2301_charger.o -obj-$(CONFIG_CHARGER_ISP1704) += isp1704_charger.o -obj-$(CONFIG_CHARGER_MAX8903) += max8903_charger.o -obj-$(CONFIG_CHARGER_TWL4030) += twl4030_charger.o -obj-$(CONFIG_CHARGER_LP8727) += lp8727_charger.o -obj-$(CONFIG_CHARGER_LP8788) += lp8788-charger.o -obj-$(CONFIG_CHARGER_GPIO) += gpio-charger.o -obj-$(CONFIG_CHARGER_MANAGER) += charger-manager.o -obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.o -obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o -obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o -obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o -obj-$(CONFIG_CHARGER_QCOM_SMBB) += qcom_smbb.o -obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o -obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o -obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o -obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o -obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o obj-$(CONFIG_POWER_AVS) += avs/ -obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o -obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o -obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o obj-$(CONFIG_POWER_RESET) += reset/ -obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o -obj-$(CONFIG_AXP288_CHARGER) += axp288_charger.o +obj-$(CONFIG_POWER_SUPPLY) += supply/ diff --git a/drivers/power/88pm860x_battery.c b/drivers/power/supply/88pm860x_battery.c similarity index 100% rename from drivers/power/88pm860x_battery.c rename to drivers/power/supply/88pm860x_battery.c diff --git a/drivers/power/88pm860x_charger.c b/drivers/power/supply/88pm860x_charger.c similarity index 100% rename from drivers/power/88pm860x_charger.c rename to drivers/power/supply/88pm860x_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig new file mode 100644 index 000000000000..76806a0be820 --- /dev/null +++ b/drivers/power/supply/Kconfig @@ -0,0 +1,514 @@ +menuconfig POWER_SUPPLY + bool "Power supply class support" + help + Say Y here to enable power supply class support. This allows + power supply (batteries, AC, USB) monitoring by userspace + via sysfs and uevent (if available) and/or APM kernel interface + (if selected below). + +if POWER_SUPPLY + +config POWER_SUPPLY_DEBUG + bool "Power supply debug" + help + Say Y here to enable debugging messages for power supply class + and drivers. + +config PDA_POWER + tristate "Generic PDA/phone power driver" + depends on !S390 + help + Say Y here to enable generic power driver for PDAs and phones with + one or two external power supplies (AC/USB) connected to main and + backup batteries, and optional builtin charger. + +config APM_POWER + tristate "APM emulation for class batteries" + depends on APM_EMULATION + help + Say Y here to enable support APM status emulation using + battery class devices. + +config GENERIC_ADC_BATTERY + tristate "Generic battery support using IIO" + depends on IIO + help + Say Y here to enable support for the generic battery driver + which uses IIO framework to read adc. + +config MAX8925_POWER + tristate "MAX8925 battery charger support" + depends on MFD_MAX8925 + help + Say Y here to enable support for the battery charger in the Maxim + MAX8925 PMIC. + +config WM831X_BACKUP + tristate "WM831X backup battery charger support" + depends on MFD_WM831X + help + Say Y here to enable support for the backup battery charger + in the Wolfson Microelectronics WM831x PMICs. + +config WM831X_POWER + tristate "WM831X PMU support" + depends on MFD_WM831X + help + Say Y here to enable support for the power management unit + provided by Wolfson Microelectronics WM831x PMICs. + +config WM8350_POWER + tristate "WM8350 PMU support" + depends on MFD_WM8350 + help + Say Y here to enable support for the power management unit + provided by the Wolfson Microelectronics WM8350 PMIC. + +config TEST_POWER + tristate "Test power driver" + help + This driver is used for testing. It's safe to say M here. + +config BATTERY_88PM860X + tristate "Marvell 88PM860x battery driver" + depends on MFD_88PM860X + help + Say Y here to enable battery monitor for Marvell 88PM860x chip. + +config BATTERY_ACT8945A + tristate "Active-semi ACT8945A charger driver" + depends on MFD_ACT8945A || COMPILE_TEST + help + Say Y here to enable support for power supply provided by + Active-semi ActivePath ACT8945A charger. + +config BATTERY_DS2760 + tristate "DS2760 battery driver (HP iPAQ & others)" + depends on W1 && W1_SLAVE_DS2760 + help + Say Y here to enable support for batteries with ds2760 chip. + +config BATTERY_DS2780 + tristate "DS2780 battery driver" + depends on HAS_IOMEM + select W1 + select W1_SLAVE_DS2780 + help + Say Y here to enable support for batteries with ds2780 chip. + +config BATTERY_DS2781 + tristate "DS2781 battery driver" + depends on HAS_IOMEM + select W1 + select W1_SLAVE_DS2781 + help + If you enable this you will have the DS2781 battery driver support. + + The battery monitor chip is used in many batteries/devices + as the one who is responsible for charging/discharging/monitoring + Li+ batteries. + + If you are unsure, say N. + +config BATTERY_DS2782 + tristate "DS2782/DS2786 standalone gas-gauge" + depends on I2C + help + Say Y here to enable support for the DS2782/DS2786 standalone battery + gas-gauge. + +config BATTERY_PMU + tristate "Apple PMU battery" + depends on PPC32 && ADB_PMU + help + Say Y here to expose battery information on Apple machines + through the generic battery class. + +config BATTERY_OLPC + tristate "One Laptop Per Child battery" + depends on X86_32 && OLPC + help + Say Y to enable support for the battery on the OLPC laptop. + +config BATTERY_TOSA + tristate "Sharp SL-6000 (tosa) battery" + depends on MACH_TOSA && MFD_TC6393XB && TOUCHSCREEN_WM97XX + help + Say Y to enable support for the battery on the Sharp Zaurus + SL-6000 (tosa) models. + +config BATTERY_COLLIE + tristate "Sharp SL-5500 (collie) battery" + depends on SA1100_COLLIE && MCP_UCB1200 + help + Say Y to enable support for the battery on the Sharp Zaurus + SL-5500 (collie) models. + +config BATTERY_IPAQ_MICRO + tristate "iPAQ Atmel Micro ASIC battery driver" + depends on MFD_IPAQ_MICRO + help + Choose this option if you want to monitor battery status on + Compaq/HP iPAQ h3100 and h3600. + +config BATTERY_WM97XX + bool "WM97xx generic battery driver" + depends on TOUCHSCREEN_WM97XX=y + help + Say Y to enable support for battery measured by WM97xx aux port. + +config BATTERY_SBS + tristate "SBS Compliant gas gauge" + depends on I2C + help + Say Y to include support for SBS battery driver for SBS-compliant + gas gauges. + +config BATTERY_BQ27XXX + tristate "BQ27xxx battery driver" + help + Say Y here to enable support for batteries with BQ27xxx chips. + +config BATTERY_BQ27XXX_I2C + tristate "BQ27xxx I2C support" + depends on BATTERY_BQ27XXX + depends on I2C + default y + help + Say Y here to enable support for batteries with BQ27xxx chips + connected over an I2C bus. + +config BATTERY_DA9030 + tristate "DA9030 battery driver" + depends on PMIC_DA903X + help + Say Y here to enable support for batteries charger integrated into + DA9030 PMIC. + +config BATTERY_DA9052 + tristate "Dialog DA9052 Battery" + depends on PMIC_DA9052 + help + Say Y here to enable support for batteries charger integrated into + DA9052 PMIC. + +config CHARGER_DA9150 + tristate "Dialog Semiconductor DA9150 Charger support" + depends on MFD_DA9150 + depends on DA9150_GPADC + depends on IIO + help + Say Y here to enable support for charger unit of the DA9150 + Integrated Charger & Fuel-Gauge IC. + + This driver can also be built as a module. If so, the module will be + called da9150-charger. + +config BATTERY_DA9150 + tristate "Dialog Semiconductor DA9150 Fuel Gauge support" + depends on MFD_DA9150 + help + Say Y here to enable support for the Fuel-Gauge unit of the DA9150 + Integrated Charger & Fuel-Gauge IC + + This driver can also be built as a module. If so, the module will be + called da9150-fg. + +config AXP288_CHARGER + tristate "X-Powers AXP288 Charger" + depends on MFD_AXP20X && EXTCON_AXP288 + help + Say yes here to have support X-Power AXP288 power management IC (PMIC) + integrated charger. + +config AXP288_FUEL_GAUGE + tristate "X-Powers AXP288 Fuel Gauge" + depends on MFD_AXP20X && IIO + help + Say yes here to have support for X-Power power management IC (PMIC) + Fuel Gauge. The device provides battery statistics and status + monitoring as well as alerts for battery over/under voltage and + over/under temperature. + +config BATTERY_MAX17040 + tristate "Maxim MAX17040 Fuel Gauge" + depends on I2C + help + MAX17040 is fuel-gauge systems for lithium-ion (Li+) batteries + in handheld and portable equipment. The MAX17040 is configured + to operate with a single lithium cell + +config BATTERY_MAX17042 + tristate "Maxim MAX17042/17047/17050/8997/8966 Fuel Gauge" + depends on I2C + select REGMAP_I2C + help + MAX17042 is fuel-gauge systems for lithium-ion (Li+) batteries + in handheld and portable equipment. The MAX17042 is configured + to operate with a single lithium cell. MAX8997 and MAX8966 are + multi-function devices that include fuel gauages that are compatible + with MAX17042. This driver also supports max17047/50 chips which are + improved version of max17042. + +config BATTERY_Z2 + tristate "Z2 battery driver" + depends on I2C && MACH_ZIPIT2 + help + Say Y to include support for the battery on the Zipit Z2. + +config BATTERY_S3C_ADC + tristate "Battery driver for Samsung ADC based monitoring" + depends on S3C_ADC + help + Say Y here to enable support for iPAQ h1930/h1940/rx1950 battery + +config BATTERY_TWL4030_MADC + tristate "TWL4030 MADC battery driver" + depends on TWL4030_MADC + help + Say Y here to enable this dumb driver for batteries managed + through the TWL4030 MADC. + +config CHARGER_88PM860X + tristate "Marvell 88PM860x Charger driver" + depends on MFD_88PM860X && BATTERY_88PM860X + help + Say Y here to enable charger for Marvell 88PM860x chip. + +config CHARGER_PCF50633 + tristate "NXP PCF50633 MBC" + depends on MFD_PCF50633 + help + Say Y to include support for NXP PCF50633 Main Battery Charger. + +config BATTERY_JZ4740 + tristate "Ingenic JZ4740 battery" + depends on MACH_JZ4740 + depends on MFD_JZ4740_ADC + help + Say Y to enable support for the battery on Ingenic JZ4740 based + boards. + + This driver can be build as a module. If so, the module will be + called jz4740-battery. + +config BATTERY_INTEL_MID + tristate "Battery driver for Intel MID platforms" + depends on INTEL_SCU_IPC && SPI + help + Say Y here to enable the battery driver on Intel MID + platforms. + +config BATTERY_RX51 + tristate "Nokia RX-51 (N900) battery driver" + depends on TWL4030_MADC + help + Say Y here to enable support for battery information on Nokia + RX-51, also known as N900 tablet. + +config CHARGER_ISP1704 + tristate "ISP1704 USB Charger Detection" + depends on USB_PHY + depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't be 'y' + help + Say Y to enable support for USB Charger Detection with + ISP1707/ISP1704 USB transceivers. + +config CHARGER_MAX8903 + tristate "MAX8903 Battery DC-DC Charger for USB and Adapter Power" + help + Say Y to enable support for the MAX8903 DC-DC charger and sysfs. + The driver supports controlling charger-enable and current-limit + pins based on the status of charger connections with interrupt + handlers. + +config CHARGER_TWL4030 + tristate "OMAP TWL4030 BCI charger driver" + depends on IIO && TWL4030_CORE + help + Say Y here to enable support for TWL4030 Battery Charge Interface. + +config CHARGER_LP8727 + tristate "TI/National Semiconductor LP8727 charger driver" + depends on I2C + help + Say Y here to enable support for LP8727 Charger Driver. + +config CHARGER_LP8788 + tristate "TI LP8788 charger driver" + depends on MFD_LP8788 + depends on LP8788_ADC + depends on IIO + help + Say Y to enable support for the LP8788 linear charger. + +config CHARGER_GPIO + tristate "GPIO charger" + depends on GPIOLIB || COMPILE_TEST + help + Say Y to include support for chargers which report their online status + through a GPIO pin. + + This driver can be build as a module. If so, the module will be + called gpio-charger. + +config CHARGER_MANAGER + bool "Battery charger manager for multiple chargers" + depends on REGULATOR + select EXTCON + help + Say Y to enable charger-manager support, which allows multiple + chargers attached to a battery and multiple batteries attached to a + system. The charger-manager also can monitor charging status in + runtime and in suspend-to-RAM by waking up the system periodically + with help of suspend_again support. + +config CHARGER_MAX14577 + tristate "Maxim MAX14577/77836 battery charger driver" + depends on MFD_MAX14577 + help + Say Y to enable support for the battery charger control sysfs and + platform data of MAX14577/77836 MUICs. + +config CHARGER_MAX77693 + tristate "Maxim MAX77693 battery charger driver" + depends on MFD_MAX77693 + help + Say Y to enable support for the Maxim MAX77693 battery charger. + +config CHARGER_MAX8997 + tristate "Maxim MAX8997/MAX8966 PMIC battery charger driver" + depends on MFD_MAX8997 && REGULATOR_MAX8997 + help + Say Y to enable support for the battery charger control sysfs and + platform data of MAX8997/LP3974 PMICs. + +config CHARGER_MAX8998 + tristate "Maxim MAX8998/LP3974 PMIC battery charger driver" + depends on MFD_MAX8998 && REGULATOR_MAX8998 + help + Say Y to enable support for the battery charger control sysfs and + platform data of MAX8998/LP3974 PMICs. + +config CHARGER_QCOM_SMBB + tristate "Qualcomm Switch-Mode Battery Charger and Boost" + depends on MFD_SPMI_PMIC || COMPILE_TEST + depends on OF + depends on EXTCON + help + Say Y to include support for the Switch-Mode Battery Charger and + Boost (SMBB) hardware found in Qualcomm PM8941 PMICs. The charger + is an integrated, single-cell lithium-ion battery charger. DT + configuration is required for loading, see the devicetree + documentation for more detail. The base name for this driver is + 'pm8941_charger'. + +config CHARGER_BQ2415X + tristate "TI BQ2415x battery charger driver" + depends on I2C + help + Say Y to enable support for the TI BQ2415x battery charger + PMICs. + + You'll need this driver to charge batteries on e.g. Nokia + RX-51/N900. + +config CHARGER_BQ24190 + tristate "TI BQ24190 battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + help + Say Y to enable support for the TI BQ24190 battery charger. + +config CHARGER_BQ24257 + tristate "TI BQ24250/24251/24257 battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + depends on REGMAP_I2C + help + Say Y to enable support for the TI BQ24250, BQ24251, and BQ24257 battery + chargers. + +config CHARGER_BQ24735 + tristate "TI BQ24735 battery charger support" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + help + Say Y to enable support for the TI BQ24735 battery charger. + +config CHARGER_BQ25890 + tristate "TI BQ25890 battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for the TI BQ25890 battery charger. + +config CHARGER_SMB347 + tristate "Summit Microelectronics SMB347 Battery Charger" + depends on I2C + select REGMAP_I2C + help + Say Y to include support for Summit Microelectronics SMB347 + Battery Charger. + +config CHARGER_TPS65090 + tristate "TPS65090 battery charger driver" + depends on MFD_TPS65090 + help + Say Y here to enable support for battery charging with TPS65090 + PMIC chips. + +config CHARGER_TPS65217 + tristate "TPS65217 battery charger driver" + depends on MFD_TPS65217 + help + Say Y here to enable support for battery charging with TPS65217 + PMIC chips. + +config BATTERY_GAUGE_LTC2941 + tristate "LTC2941/LTC2943 Battery Gauge Driver" + depends on I2C + help + Say Y here to include support for LTC2941 and LTC2943 Battery + Gauge IC. The driver reports the charge count continuously, and + measures the voltage and temperature every 10 seconds. + +config AB8500_BM + bool "AB8500 Battery Management Driver" + depends on AB8500_CORE && AB8500_GPADC + help + Say Y to include support for AB8500 battery management. + +config BATTERY_GOLDFISH + tristate "Goldfish battery driver" + depends on GOLDFISH || COMPILE_TEST + depends on HAS_IOMEM + help + Say Y to enable support for the battery and AC power in the + Goldfish emulator. + +config BATTERY_RT5033 + tristate "RT5033 fuel gauge support" + depends on MFD_RT5033 + help + This adds support for battery fuel gauge in Richtek RT5033 PMIC. + The fuelgauge calculates and determines the battery state of charge + according to battery open circuit voltage. + +config CHARGER_RT9455 + tristate "Richtek RT9455 battery charger driver" + depends on I2C + depends on GPIOLIB || COMPILE_TEST + select REGMAP_I2C + help + Say Y to enable support for Richtek RT9455 battery charger. + +config AXP20X_POWER + tristate "AXP20x power supply driver" + depends on MFD_AXP20X + help + This driver provides support for the power supply features of + AXP20x PMIC. + +endif # POWER_SUPPLY diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile new file mode 100644 index 000000000000..36c599d9a495 --- /dev/null +++ b/drivers/power/supply/Makefile @@ -0,0 +1,74 @@ +subdir-ccflags-$(CONFIG_POWER_SUPPLY_DEBUG) := -DDEBUG + +power_supply-y := power_supply_core.o +power_supply-$(CONFIG_SYSFS) += power_supply_sysfs.o +power_supply-$(CONFIG_LEDS_TRIGGERS) += power_supply_leds.o + +obj-$(CONFIG_POWER_SUPPLY) += power_supply.o +obj-$(CONFIG_GENERIC_ADC_BATTERY) += generic-adc-battery.o + +obj-$(CONFIG_PDA_POWER) += pda_power.o +obj-$(CONFIG_APM_POWER) += apm_power.o +obj-$(CONFIG_AXP20X_POWER) += axp20x_usb_power.o +obj-$(CONFIG_MAX8925_POWER) += max8925_power.o +obj-$(CONFIG_WM831X_BACKUP) += wm831x_backup.o +obj-$(CONFIG_WM831X_POWER) += wm831x_power.o +obj-$(CONFIG_WM8350_POWER) += wm8350_power.o +obj-$(CONFIG_TEST_POWER) += test_power.o + +obj-$(CONFIG_BATTERY_88PM860X) += 88pm860x_battery.o +obj-$(CONFIG_BATTERY_ACT8945A) += act8945a_charger.o +obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o +obj-$(CONFIG_BATTERY_DS2780) += ds2780_battery.o +obj-$(CONFIG_BATTERY_DS2781) += ds2781_battery.o +obj-$(CONFIG_BATTERY_DS2782) += ds2782_battery.o +obj-$(CONFIG_BATTERY_GAUGE_LTC2941) += ltc2941-battery-gauge.o +obj-$(CONFIG_BATTERY_GOLDFISH) += goldfish_battery.o +obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o +obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o +obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o +obj-$(CONFIG_BATTERY_COLLIE) += collie_battery.o +obj-$(CONFIG_BATTERY_IPAQ_MICRO) += ipaq_micro_battery.o +obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o +obj-$(CONFIG_BATTERY_SBS) += sbs-battery.o +obj-$(CONFIG_BATTERY_BQ27XXX) += bq27xxx_battery.o +obj-$(CONFIG_BATTERY_BQ27XXX_I2C) += bq27xxx_battery_i2c.o +obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o +obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o +obj-$(CONFIG_CHARGER_DA9150) += da9150-charger.o +obj-$(CONFIG_BATTERY_DA9150) += da9150-fg.o +obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o +obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o +obj-$(CONFIG_BATTERY_Z2) += z2_battery.o +obj-$(CONFIG_BATTERY_RT5033) += rt5033_battery.o +obj-$(CONFIG_CHARGER_RT9455) += rt9455_charger.o +obj-$(CONFIG_BATTERY_S3C_ADC) += s3c_adc_battery.o +obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o +obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o +obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o +obj-$(CONFIG_BATTERY_JZ4740) += jz4740-battery.o +obj-$(CONFIG_BATTERY_INTEL_MID) += intel_mid_battery.o +obj-$(CONFIG_BATTERY_RX51) += rx51_battery.o +obj-$(CONFIG_AB8500_BM) += ab8500_bmdata.o ab8500_charger.o ab8500_fg.o ab8500_btemp.o abx500_chargalg.o pm2301_charger.o +obj-$(CONFIG_CHARGER_ISP1704) += isp1704_charger.o +obj-$(CONFIG_CHARGER_MAX8903) += max8903_charger.o +obj-$(CONFIG_CHARGER_TWL4030) += twl4030_charger.o +obj-$(CONFIG_CHARGER_LP8727) += lp8727_charger.o +obj-$(CONFIG_CHARGER_LP8788) += lp8788-charger.o +obj-$(CONFIG_CHARGER_GPIO) += gpio-charger.o +obj-$(CONFIG_CHARGER_MANAGER) += charger-manager.o +obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.o +obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o +obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o +obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o +obj-$(CONFIG_CHARGER_QCOM_SMBB) += qcom_smbb.o +obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o +obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o +obj-$(CONFIG_CHARGER_BQ24257) += bq24257_charger.o +obj-$(CONFIG_CHARGER_BQ24735) += bq24735-charger.o +obj-$(CONFIG_CHARGER_BQ25890) += bq25890_charger.o +obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o +obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o +obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o +obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o +obj-$(CONFIG_AXP288_CHARGER) += axp288_charger.o diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/supply/ab8500_bmdata.c similarity index 100% rename from drivers/power/ab8500_bmdata.c rename to drivers/power/supply/ab8500_bmdata.c diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c similarity index 100% rename from drivers/power/ab8500_btemp.c rename to drivers/power/supply/ab8500_btemp.c diff --git a/drivers/power/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c similarity index 100% rename from drivers/power/ab8500_charger.c rename to drivers/power/supply/ab8500_charger.c diff --git a/drivers/power/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c similarity index 100% rename from drivers/power/ab8500_fg.c rename to drivers/power/supply/ab8500_fg.c diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/supply/abx500_chargalg.c similarity index 100% rename from drivers/power/abx500_chargalg.c rename to drivers/power/supply/abx500_chargalg.c diff --git a/drivers/power/act8945a_charger.c b/drivers/power/supply/act8945a_charger.c similarity index 100% rename from drivers/power/act8945a_charger.c rename to drivers/power/supply/act8945a_charger.c diff --git a/drivers/power/apm_power.c b/drivers/power/supply/apm_power.c similarity index 100% rename from drivers/power/apm_power.c rename to drivers/power/supply/apm_power.c diff --git a/drivers/power/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c similarity index 100% rename from drivers/power/axp20x_usb_power.c rename to drivers/power/supply/axp20x_usb_power.c diff --git a/drivers/power/axp288_charger.c b/drivers/power/supply/axp288_charger.c similarity index 100% rename from drivers/power/axp288_charger.c rename to drivers/power/supply/axp288_charger.c diff --git a/drivers/power/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c similarity index 100% rename from drivers/power/axp288_fuel_gauge.c rename to drivers/power/supply/axp288_fuel_gauge.c diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/supply/bq2415x_charger.c similarity index 100% rename from drivers/power/bq2415x_charger.c rename to drivers/power/supply/bq2415x_charger.c diff --git a/drivers/power/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c similarity index 100% rename from drivers/power/bq24190_charger.c rename to drivers/power/supply/bq24190_charger.c diff --git a/drivers/power/bq24257_charger.c b/drivers/power/supply/bq24257_charger.c similarity index 100% rename from drivers/power/bq24257_charger.c rename to drivers/power/supply/bq24257_charger.c diff --git a/drivers/power/bq24735-charger.c b/drivers/power/supply/bq24735-charger.c similarity index 100% rename from drivers/power/bq24735-charger.c rename to drivers/power/supply/bq24735-charger.c diff --git a/drivers/power/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c similarity index 100% rename from drivers/power/bq25890_charger.c rename to drivers/power/supply/bq25890_charger.c diff --git a/drivers/power/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c similarity index 100% rename from drivers/power/bq27xxx_battery.c rename to drivers/power/supply/bq27xxx_battery.c diff --git a/drivers/power/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c similarity index 100% rename from drivers/power/bq27xxx_battery_i2c.c rename to drivers/power/supply/bq27xxx_battery_i2c.c diff --git a/drivers/power/charger-manager.c b/drivers/power/supply/charger-manager.c similarity index 100% rename from drivers/power/charger-manager.c rename to drivers/power/supply/charger-manager.c diff --git a/drivers/power/collie_battery.c b/drivers/power/supply/collie_battery.c similarity index 100% rename from drivers/power/collie_battery.c rename to drivers/power/supply/collie_battery.c diff --git a/drivers/power/da9030_battery.c b/drivers/power/supply/da9030_battery.c similarity index 100% rename from drivers/power/da9030_battery.c rename to drivers/power/supply/da9030_battery.c diff --git a/drivers/power/da9052-battery.c b/drivers/power/supply/da9052-battery.c similarity index 100% rename from drivers/power/da9052-battery.c rename to drivers/power/supply/da9052-battery.c diff --git a/drivers/power/da9150-charger.c b/drivers/power/supply/da9150-charger.c similarity index 100% rename from drivers/power/da9150-charger.c rename to drivers/power/supply/da9150-charger.c diff --git a/drivers/power/da9150-fg.c b/drivers/power/supply/da9150-fg.c similarity index 100% rename from drivers/power/da9150-fg.c rename to drivers/power/supply/da9150-fg.c diff --git a/drivers/power/ds2760_battery.c b/drivers/power/supply/ds2760_battery.c similarity index 99% rename from drivers/power/ds2760_battery.c rename to drivers/power/supply/ds2760_battery.c index 80f73ccb77ab..369ab00bf453 100644 --- a/drivers/power/ds2760_battery.c +++ b/drivers/power/supply/ds2760_battery.c @@ -28,8 +28,8 @@ #include #include -#include "../w1/w1.h" -#include "../w1/slaves/w1_ds2760.h" +#include "../../w1/w1.h" +#include "../../w1/slaves/w1_ds2760.h" struct ds2760_device_info { struct device *dev; diff --git a/drivers/power/ds2780_battery.c b/drivers/power/supply/ds2780_battery.c similarity index 99% rename from drivers/power/ds2780_battery.c rename to drivers/power/supply/ds2780_battery.c index d3743d0ad55b..1b3b6fa89c28 100644 --- a/drivers/power/ds2780_battery.c +++ b/drivers/power/supply/ds2780_battery.c @@ -21,8 +21,8 @@ #include #include -#include "../w1/w1.h" -#include "../w1/slaves/w1_ds2780.h" +#include "../../w1/w1.h" +#include "../../w1/slaves/w1_ds2780.h" /* Current unit measurement in uA for a 1 milli-ohm sense resistor */ #define DS2780_CURRENT_UNITS 1563 diff --git a/drivers/power/ds2781_battery.c b/drivers/power/supply/ds2781_battery.c similarity index 99% rename from drivers/power/ds2781_battery.c rename to drivers/power/supply/ds2781_battery.c index c3680024f399..cc0149131f89 100644 --- a/drivers/power/ds2781_battery.c +++ b/drivers/power/supply/ds2781_battery.c @@ -19,8 +19,8 @@ #include #include -#include "../w1/w1.h" -#include "../w1/slaves/w1_ds2781.h" +#include "../../w1/w1.h" +#include "../../w1/slaves/w1_ds2781.h" /* Current unit measurement in uA for a 1 milli-ohm sense resistor */ #define DS2781_CURRENT_UNITS 1563 diff --git a/drivers/power/ds2782_battery.c b/drivers/power/supply/ds2782_battery.c similarity index 100% rename from drivers/power/ds2782_battery.c rename to drivers/power/supply/ds2782_battery.c diff --git a/drivers/power/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c similarity index 100% rename from drivers/power/generic-adc-battery.c rename to drivers/power/supply/generic-adc-battery.c diff --git a/drivers/power/goldfish_battery.c b/drivers/power/supply/goldfish_battery.c similarity index 100% rename from drivers/power/goldfish_battery.c rename to drivers/power/supply/goldfish_battery.c diff --git a/drivers/power/gpio-charger.c b/drivers/power/supply/gpio-charger.c similarity index 100% rename from drivers/power/gpio-charger.c rename to drivers/power/supply/gpio-charger.c diff --git a/drivers/power/intel_mid_battery.c b/drivers/power/supply/intel_mid_battery.c similarity index 100% rename from drivers/power/intel_mid_battery.c rename to drivers/power/supply/intel_mid_battery.c diff --git a/drivers/power/ipaq_micro_battery.c b/drivers/power/supply/ipaq_micro_battery.c similarity index 100% rename from drivers/power/ipaq_micro_battery.c rename to drivers/power/supply/ipaq_micro_battery.c diff --git a/drivers/power/isp1704_charger.c b/drivers/power/supply/isp1704_charger.c similarity index 100% rename from drivers/power/isp1704_charger.c rename to drivers/power/supply/isp1704_charger.c diff --git a/drivers/power/jz4740-battery.c b/drivers/power/supply/jz4740-battery.c similarity index 100% rename from drivers/power/jz4740-battery.c rename to drivers/power/supply/jz4740-battery.c diff --git a/drivers/power/lp8727_charger.c b/drivers/power/supply/lp8727_charger.c similarity index 100% rename from drivers/power/lp8727_charger.c rename to drivers/power/supply/lp8727_charger.c diff --git a/drivers/power/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c similarity index 100% rename from drivers/power/lp8788-charger.c rename to drivers/power/supply/lp8788-charger.c diff --git a/drivers/power/ltc2941-battery-gauge.c b/drivers/power/supply/ltc2941-battery-gauge.c similarity index 100% rename from drivers/power/ltc2941-battery-gauge.c rename to drivers/power/supply/ltc2941-battery-gauge.c diff --git a/drivers/power/max14577_charger.c b/drivers/power/supply/max14577_charger.c similarity index 100% rename from drivers/power/max14577_charger.c rename to drivers/power/supply/max14577_charger.c diff --git a/drivers/power/max17040_battery.c b/drivers/power/supply/max17040_battery.c similarity index 100% rename from drivers/power/max17040_battery.c rename to drivers/power/supply/max17040_battery.c diff --git a/drivers/power/max17042_battery.c b/drivers/power/supply/max17042_battery.c similarity index 100% rename from drivers/power/max17042_battery.c rename to drivers/power/supply/max17042_battery.c diff --git a/drivers/power/max77693_charger.c b/drivers/power/supply/max77693_charger.c similarity index 100% rename from drivers/power/max77693_charger.c rename to drivers/power/supply/max77693_charger.c diff --git a/drivers/power/max8903_charger.c b/drivers/power/supply/max8903_charger.c similarity index 100% rename from drivers/power/max8903_charger.c rename to drivers/power/supply/max8903_charger.c diff --git a/drivers/power/max8925_power.c b/drivers/power/supply/max8925_power.c similarity index 100% rename from drivers/power/max8925_power.c rename to drivers/power/supply/max8925_power.c diff --git a/drivers/power/max8997_charger.c b/drivers/power/supply/max8997_charger.c similarity index 100% rename from drivers/power/max8997_charger.c rename to drivers/power/supply/max8997_charger.c diff --git a/drivers/power/max8998_charger.c b/drivers/power/supply/max8998_charger.c similarity index 100% rename from drivers/power/max8998_charger.c rename to drivers/power/supply/max8998_charger.c diff --git a/drivers/power/olpc_battery.c b/drivers/power/supply/olpc_battery.c similarity index 100% rename from drivers/power/olpc_battery.c rename to drivers/power/supply/olpc_battery.c diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/supply/pcf50633-charger.c similarity index 100% rename from drivers/power/pcf50633-charger.c rename to drivers/power/supply/pcf50633-charger.c diff --git a/drivers/power/pda_power.c b/drivers/power/supply/pda_power.c similarity index 100% rename from drivers/power/pda_power.c rename to drivers/power/supply/pda_power.c diff --git a/drivers/power/pm2301_charger.c b/drivers/power/supply/pm2301_charger.c similarity index 100% rename from drivers/power/pm2301_charger.c rename to drivers/power/supply/pm2301_charger.c diff --git a/drivers/power/pm2301_charger.h b/drivers/power/supply/pm2301_charger.h similarity index 100% rename from drivers/power/pm2301_charger.h rename to drivers/power/supply/pm2301_charger.h diff --git a/drivers/power/pmu_battery.c b/drivers/power/supply/pmu_battery.c similarity index 100% rename from drivers/power/pmu_battery.c rename to drivers/power/supply/pmu_battery.c diff --git a/drivers/power/power_supply.h b/drivers/power/supply/power_supply.h similarity index 100% rename from drivers/power/power_supply.h rename to drivers/power/supply/power_supply.h diff --git a/drivers/power/power_supply_core.c b/drivers/power/supply/power_supply_core.c similarity index 100% rename from drivers/power/power_supply_core.c rename to drivers/power/supply/power_supply_core.c diff --git a/drivers/power/power_supply_leds.c b/drivers/power/supply/power_supply_leds.c similarity index 100% rename from drivers/power/power_supply_leds.c rename to drivers/power/supply/power_supply_leds.c diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c similarity index 100% rename from drivers/power/power_supply_sysfs.c rename to drivers/power/supply/power_supply_sysfs.c diff --git a/drivers/power/qcom_smbb.c b/drivers/power/supply/qcom_smbb.c similarity index 100% rename from drivers/power/qcom_smbb.c rename to drivers/power/supply/qcom_smbb.c diff --git a/drivers/power/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c similarity index 100% rename from drivers/power/rt5033_battery.c rename to drivers/power/supply/rt5033_battery.c diff --git a/drivers/power/rt9455_charger.c b/drivers/power/supply/rt9455_charger.c similarity index 100% rename from drivers/power/rt9455_charger.c rename to drivers/power/supply/rt9455_charger.c diff --git a/drivers/power/rx51_battery.c b/drivers/power/supply/rx51_battery.c similarity index 100% rename from drivers/power/rx51_battery.c rename to drivers/power/supply/rx51_battery.c diff --git a/drivers/power/s3c_adc_battery.c b/drivers/power/supply/s3c_adc_battery.c similarity index 100% rename from drivers/power/s3c_adc_battery.c rename to drivers/power/supply/s3c_adc_battery.c diff --git a/drivers/power/sbs-battery.c b/drivers/power/supply/sbs-battery.c similarity index 100% rename from drivers/power/sbs-battery.c rename to drivers/power/supply/sbs-battery.c diff --git a/drivers/power/smb347-charger.c b/drivers/power/supply/smb347-charger.c similarity index 100% rename from drivers/power/smb347-charger.c rename to drivers/power/supply/smb347-charger.c diff --git a/drivers/power/test_power.c b/drivers/power/supply/test_power.c similarity index 100% rename from drivers/power/test_power.c rename to drivers/power/supply/test_power.c diff --git a/drivers/power/tosa_battery.c b/drivers/power/supply/tosa_battery.c similarity index 100% rename from drivers/power/tosa_battery.c rename to drivers/power/supply/tosa_battery.c diff --git a/drivers/power/tps65090-charger.c b/drivers/power/supply/tps65090-charger.c similarity index 100% rename from drivers/power/tps65090-charger.c rename to drivers/power/supply/tps65090-charger.c diff --git a/drivers/power/tps65217_charger.c b/drivers/power/supply/tps65217_charger.c similarity index 100% rename from drivers/power/tps65217_charger.c rename to drivers/power/supply/tps65217_charger.c diff --git a/drivers/power/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c similarity index 100% rename from drivers/power/twl4030_charger.c rename to drivers/power/supply/twl4030_charger.c diff --git a/drivers/power/twl4030_madc_battery.c b/drivers/power/supply/twl4030_madc_battery.c similarity index 100% rename from drivers/power/twl4030_madc_battery.c rename to drivers/power/supply/twl4030_madc_battery.c diff --git a/drivers/power/wm831x_backup.c b/drivers/power/supply/wm831x_backup.c similarity index 100% rename from drivers/power/wm831x_backup.c rename to drivers/power/supply/wm831x_backup.c diff --git a/drivers/power/wm831x_power.c b/drivers/power/supply/wm831x_power.c similarity index 100% rename from drivers/power/wm831x_power.c rename to drivers/power/supply/wm831x_power.c diff --git a/drivers/power/wm8350_power.c b/drivers/power/supply/wm8350_power.c similarity index 100% rename from drivers/power/wm8350_power.c rename to drivers/power/supply/wm8350_power.c diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/supply/wm97xx_battery.c similarity index 99% rename from drivers/power/wm97xx_battery.c rename to drivers/power/supply/wm97xx_battery.c index c2f09ed35050..6285626d142a 100644 --- a/drivers/power/wm97xx_battery.c +++ b/drivers/power/supply/wm97xx_battery.c @@ -1,6 +1,4 @@ /* - * linux/drivers/power/wm97xx_battery.c - * * Battery measurement code for WM97xx * * based on tosa_battery.c diff --git a/drivers/power/z2_battery.c b/drivers/power/supply/z2_battery.c similarity index 100% rename from drivers/power/z2_battery.c rename to drivers/power/supply/z2_battery.c From f3332532463fef7d56507c08b33993db398d7a91 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 17 Jun 2016 14:12:47 +0200 Subject: [PATCH 02/46] power/supply: unify DT documentation Currently the power supply device tree documentation is spread in .../bindings/power_supply and .../bindings/power. This unifies the files for chargers and battery fuel gauges in .../bindings/power/supply and the ones for system reset/shutdown in .../bindings/power/reset (same structure as used for the drivers itself). Signed-off-by: Sebastian Reichel --- .../bindings/{power_supply => power/reset}/axxia-reset.txt | 0 .../{power_supply => power/reset}/imx-snvs-poweroff.txt | 0 .../bindings/{power_supply => power/reset}/msm-poweroff.txt | 0 .../bindings/{power_supply => power/reset}/qnap-poweroff.txt | 0 .../{power_supply => power/reset}/restart-poweroff.txt | 0 .../bindings/{power_supply => power/supply}/ab8500/btemp.txt | 0 .../{power_supply => power/supply}/ab8500/chargalg.txt | 0 .../bindings/{power_supply => power/supply}/ab8500/charger.txt | 0 .../bindings/{power_supply => power/supply}/ab8500/fg.txt | 0 .../bindings/power/{ => supply}/act8945a-charger.txt | 0 .../{power_supply => power/supply}/axp20x_usb_power.txt | 0 .../devicetree/bindings/power/{ => supply}/bq2415x.txt | 0 .../devicetree/bindings/power/{ => supply}/bq24257.txt | 0 .../devicetree/bindings/power/{ => supply}/bq25890.txt | 0 .../{power_supply => power/supply}/charger-manager.txt | 0 .../devicetree/bindings/power/{ => supply}/da9150-charger.txt | 0 .../devicetree/bindings/power/{ => supply}/da9150-fg.txt | 0 .../bindings/{power_supply => power/supply}/gpio-charger.txt | 0 .../devicetree/bindings/power/{ => supply}/isp1704.txt | 0 .../bindings/{power_supply => power/supply}/lp8727_charger.txt | 0 .../devicetree/bindings/power/{ => supply}/ltc2941.txt | 0 .../{power_supply => power/supply}/max17042_battery.txt | 0 .../bindings/{power_supply => power/supply}/max8925_batter.txt | 0 .../bindings/{power_supply => power/supply}/olpc_battery.txt | 0 .../bindings/{power_supply => power/supply}/power_supply.txt | 0 .../bindings/power/{ => supply}/qcom,coincell-charger.txt | 0 .../bindings/{power_supply => power/supply}/qcom_smbb.txt | 0 .../devicetree/bindings/power/{ => supply}/rt9455_charger.txt | 0 .../devicetree/bindings/power/{ => supply}/rx51-battery.txt | 0 .../{power_supply => power/supply}/sbs_sbs-battery.txt | 0 .../bindings/{power_supply => power/supply}/ti,bq24735.txt | 0 .../bindings/{power_supply => power/supply}/tps65090.txt | 0 .../{power_supply => power/supply}/tps65217_charger.txt | 0 .../devicetree/bindings/power/{ => supply}/twl-charger.txt | 0 MAINTAINERS | 3 +-- 35 files changed, 1 insertion(+), 2 deletions(-) rename Documentation/devicetree/bindings/{power_supply => power/reset}/axxia-reset.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/reset}/imx-snvs-poweroff.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/reset}/msm-poweroff.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/reset}/qnap-poweroff.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/reset}/restart-poweroff.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/ab8500/btemp.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/ab8500/chargalg.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/ab8500/charger.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/ab8500/fg.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/act8945a-charger.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/axp20x_usb_power.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/bq2415x.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/bq24257.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/bq25890.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/charger-manager.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/da9150-charger.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/da9150-fg.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/gpio-charger.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/isp1704.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/lp8727_charger.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/ltc2941.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/max17042_battery.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/max8925_batter.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/olpc_battery.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/power_supply.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/qcom,coincell-charger.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/qcom_smbb.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/rt9455_charger.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/rx51-battery.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/sbs_sbs-battery.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/ti,bq24735.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/tps65090.txt (100%) rename Documentation/devicetree/bindings/{power_supply => power/supply}/tps65217_charger.txt (100%) rename Documentation/devicetree/bindings/power/{ => supply}/twl-charger.txt (100%) diff --git a/Documentation/devicetree/bindings/power_supply/axxia-reset.txt b/Documentation/devicetree/bindings/power/reset/axxia-reset.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/axxia-reset.txt rename to Documentation/devicetree/bindings/power/reset/axxia-reset.txt diff --git a/Documentation/devicetree/bindings/power_supply/imx-snvs-poweroff.txt b/Documentation/devicetree/bindings/power/reset/imx-snvs-poweroff.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/imx-snvs-poweroff.txt rename to Documentation/devicetree/bindings/power/reset/imx-snvs-poweroff.txt diff --git a/Documentation/devicetree/bindings/power_supply/msm-poweroff.txt b/Documentation/devicetree/bindings/power/reset/msm-poweroff.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/msm-poweroff.txt rename to Documentation/devicetree/bindings/power/reset/msm-poweroff.txt diff --git a/Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt b/Documentation/devicetree/bindings/power/reset/qnap-poweroff.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt rename to Documentation/devicetree/bindings/power/reset/qnap-poweroff.txt diff --git a/Documentation/devicetree/bindings/power_supply/restart-poweroff.txt b/Documentation/devicetree/bindings/power/reset/restart-poweroff.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/restart-poweroff.txt rename to Documentation/devicetree/bindings/power/reset/restart-poweroff.txt diff --git a/Documentation/devicetree/bindings/power_supply/ab8500/btemp.txt b/Documentation/devicetree/bindings/power/supply/ab8500/btemp.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/ab8500/btemp.txt rename to Documentation/devicetree/bindings/power/supply/ab8500/btemp.txt diff --git a/Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt b/Documentation/devicetree/bindings/power/supply/ab8500/chargalg.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/ab8500/chargalg.txt rename to Documentation/devicetree/bindings/power/supply/ab8500/chargalg.txt diff --git a/Documentation/devicetree/bindings/power_supply/ab8500/charger.txt b/Documentation/devicetree/bindings/power/supply/ab8500/charger.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/ab8500/charger.txt rename to Documentation/devicetree/bindings/power/supply/ab8500/charger.txt diff --git a/Documentation/devicetree/bindings/power_supply/ab8500/fg.txt b/Documentation/devicetree/bindings/power/supply/ab8500/fg.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/ab8500/fg.txt rename to Documentation/devicetree/bindings/power/supply/ab8500/fg.txt diff --git a/Documentation/devicetree/bindings/power/act8945a-charger.txt b/Documentation/devicetree/bindings/power/supply/act8945a-charger.txt similarity index 100% rename from Documentation/devicetree/bindings/power/act8945a-charger.txt rename to Documentation/devicetree/bindings/power/supply/act8945a-charger.txt diff --git a/Documentation/devicetree/bindings/power_supply/axp20x_usb_power.txt b/Documentation/devicetree/bindings/power/supply/axp20x_usb_power.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/axp20x_usb_power.txt rename to Documentation/devicetree/bindings/power/supply/axp20x_usb_power.txt diff --git a/Documentation/devicetree/bindings/power/bq2415x.txt b/Documentation/devicetree/bindings/power/supply/bq2415x.txt similarity index 100% rename from Documentation/devicetree/bindings/power/bq2415x.txt rename to Documentation/devicetree/bindings/power/supply/bq2415x.txt diff --git a/Documentation/devicetree/bindings/power/bq24257.txt b/Documentation/devicetree/bindings/power/supply/bq24257.txt similarity index 100% rename from Documentation/devicetree/bindings/power/bq24257.txt rename to Documentation/devicetree/bindings/power/supply/bq24257.txt diff --git a/Documentation/devicetree/bindings/power/bq25890.txt b/Documentation/devicetree/bindings/power/supply/bq25890.txt similarity index 100% rename from Documentation/devicetree/bindings/power/bq25890.txt rename to Documentation/devicetree/bindings/power/supply/bq25890.txt diff --git a/Documentation/devicetree/bindings/power_supply/charger-manager.txt b/Documentation/devicetree/bindings/power/supply/charger-manager.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/charger-manager.txt rename to Documentation/devicetree/bindings/power/supply/charger-manager.txt diff --git a/Documentation/devicetree/bindings/power/da9150-charger.txt b/Documentation/devicetree/bindings/power/supply/da9150-charger.txt similarity index 100% rename from Documentation/devicetree/bindings/power/da9150-charger.txt rename to Documentation/devicetree/bindings/power/supply/da9150-charger.txt diff --git a/Documentation/devicetree/bindings/power/da9150-fg.txt b/Documentation/devicetree/bindings/power/supply/da9150-fg.txt similarity index 100% rename from Documentation/devicetree/bindings/power/da9150-fg.txt rename to Documentation/devicetree/bindings/power/supply/da9150-fg.txt diff --git a/Documentation/devicetree/bindings/power_supply/gpio-charger.txt b/Documentation/devicetree/bindings/power/supply/gpio-charger.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/gpio-charger.txt rename to Documentation/devicetree/bindings/power/supply/gpio-charger.txt diff --git a/Documentation/devicetree/bindings/power/isp1704.txt b/Documentation/devicetree/bindings/power/supply/isp1704.txt similarity index 100% rename from Documentation/devicetree/bindings/power/isp1704.txt rename to Documentation/devicetree/bindings/power/supply/isp1704.txt diff --git a/Documentation/devicetree/bindings/power_supply/lp8727_charger.txt b/Documentation/devicetree/bindings/power/supply/lp8727_charger.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/lp8727_charger.txt rename to Documentation/devicetree/bindings/power/supply/lp8727_charger.txt diff --git a/Documentation/devicetree/bindings/power/ltc2941.txt b/Documentation/devicetree/bindings/power/supply/ltc2941.txt similarity index 100% rename from Documentation/devicetree/bindings/power/ltc2941.txt rename to Documentation/devicetree/bindings/power/supply/ltc2941.txt diff --git a/Documentation/devicetree/bindings/power_supply/max17042_battery.txt b/Documentation/devicetree/bindings/power/supply/max17042_battery.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/max17042_battery.txt rename to Documentation/devicetree/bindings/power/supply/max17042_battery.txt diff --git a/Documentation/devicetree/bindings/power_supply/max8925_batter.txt b/Documentation/devicetree/bindings/power/supply/max8925_batter.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/max8925_batter.txt rename to Documentation/devicetree/bindings/power/supply/max8925_batter.txt diff --git a/Documentation/devicetree/bindings/power_supply/olpc_battery.txt b/Documentation/devicetree/bindings/power/supply/olpc_battery.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/olpc_battery.txt rename to Documentation/devicetree/bindings/power/supply/olpc_battery.txt diff --git a/Documentation/devicetree/bindings/power_supply/power_supply.txt b/Documentation/devicetree/bindings/power/supply/power_supply.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/power_supply.txt rename to Documentation/devicetree/bindings/power/supply/power_supply.txt diff --git a/Documentation/devicetree/bindings/power/qcom,coincell-charger.txt b/Documentation/devicetree/bindings/power/supply/qcom,coincell-charger.txt similarity index 100% rename from Documentation/devicetree/bindings/power/qcom,coincell-charger.txt rename to Documentation/devicetree/bindings/power/supply/qcom,coincell-charger.txt diff --git a/Documentation/devicetree/bindings/power_supply/qcom_smbb.txt b/Documentation/devicetree/bindings/power/supply/qcom_smbb.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/qcom_smbb.txt rename to Documentation/devicetree/bindings/power/supply/qcom_smbb.txt diff --git a/Documentation/devicetree/bindings/power/rt9455_charger.txt b/Documentation/devicetree/bindings/power/supply/rt9455_charger.txt similarity index 100% rename from Documentation/devicetree/bindings/power/rt9455_charger.txt rename to Documentation/devicetree/bindings/power/supply/rt9455_charger.txt diff --git a/Documentation/devicetree/bindings/power/rx51-battery.txt b/Documentation/devicetree/bindings/power/supply/rx51-battery.txt similarity index 100% rename from Documentation/devicetree/bindings/power/rx51-battery.txt rename to Documentation/devicetree/bindings/power/supply/rx51-battery.txt diff --git a/Documentation/devicetree/bindings/power_supply/sbs_sbs-battery.txt b/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/sbs_sbs-battery.txt rename to Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt diff --git a/Documentation/devicetree/bindings/power_supply/ti,bq24735.txt b/Documentation/devicetree/bindings/power/supply/ti,bq24735.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/ti,bq24735.txt rename to Documentation/devicetree/bindings/power/supply/ti,bq24735.txt diff --git a/Documentation/devicetree/bindings/power_supply/tps65090.txt b/Documentation/devicetree/bindings/power/supply/tps65090.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/tps65090.txt rename to Documentation/devicetree/bindings/power/supply/tps65090.txt diff --git a/Documentation/devicetree/bindings/power_supply/tps65217_charger.txt b/Documentation/devicetree/bindings/power/supply/tps65217_charger.txt similarity index 100% rename from Documentation/devicetree/bindings/power_supply/tps65217_charger.txt rename to Documentation/devicetree/bindings/power/supply/tps65217_charger.txt diff --git a/Documentation/devicetree/bindings/power/twl-charger.txt b/Documentation/devicetree/bindings/power/supply/twl-charger.txt similarity index 100% rename from Documentation/devicetree/bindings/power/twl-charger.txt rename to Documentation/devicetree/bindings/power/supply/twl-charger.txt diff --git a/MAINTAINERS b/MAINTAINERS index ca66b4140c50..c7d6762424a1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9331,8 +9331,7 @@ M: David Woodhouse L: linux-pm@vger.kernel.org T: git git://git.infradead.org/battery-2.6.git S: Maintained -F: Documentation/devicetree/bindings/power/ -F: Documentation/devicetree/bindings/power_supply/ +F: Documentation/devicetree/bindings/power/supply/ F: include/linux/power_supply.h F: drivers/power/supply/ From 47d7d5ed68d877269003a392b7008905d65650bb Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Mon, 20 Jun 2016 12:50:54 +0200 Subject: [PATCH 03/46] power_supply: tps65217-charger: Add support for IRQs Make use of IRQ resources defined in tps65217 mfd code. If they are valid we use them instead separate poll task, in order to define AC power state. Signed-off-by: Marcin Niestroj Signed-off-by: Sebastian Reichel --- drivers/power/supply/tps65217_charger.c | 40 ++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/drivers/power/supply/tps65217_charger.c b/drivers/power/supply/tps65217_charger.c index 73dfae41def8..c8c4a0c1dca5 100644 --- a/drivers/power/supply/tps65217_charger.c +++ b/drivers/power/supply/tps65217_charger.c @@ -46,6 +46,8 @@ struct tps65217_charger { int prev_ac_online; struct task_struct *poll_task; + + int irq; }; static enum power_supply_property tps65217_ac_props[] = { @@ -198,6 +200,7 @@ static int tps65217_charger_probe(struct platform_device *pdev) struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); struct tps65217_charger *charger; struct power_supply_config cfg = {}; + int irq; int ret; dev_dbg(&pdev->dev, "%s\n", __func__); @@ -220,18 +223,40 @@ static int tps65217_charger_probe(struct platform_device *pdev) return PTR_ERR(charger->ac); } + irq = platform_get_irq_byname(pdev, "AC"); + if (irq < 0) + irq = -ENXIO; + charger->irq = irq; + ret = tps65217_config_charger(charger); if (ret < 0) { dev_err(charger->dev, "charger config failed, err %d\n", ret); return ret; } - charger->poll_task = kthread_run(tps65217_charger_poll_task, - charger, "ktps65217charger"); - if (IS_ERR(charger->poll_task)) { - ret = PTR_ERR(charger->poll_task); - dev_err(charger->dev, "Unable to run kthread err %d\n", ret); - return ret; + if (irq != -ENXIO) { + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + tps65217_charger_irq, + 0, "tps65217-charger", + charger); + if (ret) { + dev_err(charger->dev, + "Unable to register irq %d err %d\n", irq, + ret); + return ret; + } + + /* Check current state */ + tps65217_charger_irq(irq, charger); + } else { + charger->poll_task = kthread_run(tps65217_charger_poll_task, + charger, "ktps65217charger"); + if (IS_ERR(charger->poll_task)) { + ret = PTR_ERR(charger->poll_task); + dev_err(charger->dev, + "Unable to run kthread err %d\n", ret); + return ret; + } } return 0; @@ -241,7 +266,8 @@ static int tps65217_charger_remove(struct platform_device *pdev) { struct tps65217_charger *charger = platform_get_drvdata(pdev); - kthread_stop(charger->poll_task); + if (charger->irq == -ENXIO) + kthread_stop(charger->poll_task); return 0; } From e4a404a081df1abe95a06ab24b7c76d8cf02402f Mon Sep 17 00:00:00 2001 From: "H. Nikolaus Schaller" Date: Mon, 18 Jul 2016 18:12:09 +0200 Subject: [PATCH 04/46] power:bq27xxx: 27000/10 read FLAGS register as single MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bq27000 and bq27010 have a single byte FLAGS register. Other gauges have 16 bit FLAGS registers. For reading the FLAGS register it is sufficient to read the single register instead of reading RSOC at the next higher address as well and then ignore the high byte. This does not change functionality but optimizes i2c and hdq traffic. Signed-off-by: H. Nikolaus Schaller Acked-by: Pali Rohár Acked-by: Andrew F. Davis Signed-off-by: Sebastian Reichel --- drivers/power/supply/bq27xxx_battery.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c index 323d05a12f9b..3f57dd54803a 100644 --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -644,8 +644,9 @@ static bool bq27xxx_battery_dead(struct bq27xxx_device_info *di, u16 flags) static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di) { int flags; + bool has_singe_flag = di->chip == BQ27000 || di->chip == BQ27010; - flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, false); + flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, has_singe_flag); if (flags < 0) { dev_err(di->dev, "error reading flag register:%d\n", flags); return flags; @@ -745,7 +746,7 @@ static int bq27xxx_battery_current(struct bq27xxx_device_info *di, } if (di->chip == BQ27000 || di->chip == BQ27010) { - flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, false); + flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, true); if (flags & BQ27000_FLAG_CHGS) { dev_dbg(di->dev, "negative current!\n"); curr = -curr; From 9239a86f0976b58d3da7a2261ed659ac9eba0f25 Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Mon, 25 Jul 2016 10:42:57 +0800 Subject: [PATCH 05/46] power: sbs-battery: Use devm_kzalloc to alloc data Use devm_kzalloc to allow memory to be freed automatically on driver probe failure or removal. Signed-off-by: Phil Reid Signed-off-by: Sebastian Reichel --- drivers/power/supply/sbs-battery.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index 768b9fcb58ea..20f3be6f5b9a 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -819,7 +819,7 @@ static int sbs_probe(struct i2c_client *client, if (!sbs_desc->name) return -ENOMEM; - chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL); + chip = devm_kzalloc(&client->dev, sizeof(struct sbs_info), GFP_KERNEL); if (!chip) return -ENOMEM; @@ -920,8 +920,6 @@ exit_psupply: if (chip->gpio_detect) gpio_free(pdata->battery_detect); - kfree(chip); - return rc; } @@ -938,9 +936,6 @@ static int sbs_remove(struct i2c_client *client) cancel_delayed_work_sync(&chip->work); - kfree(chip); - chip = NULL; - return 0; } From d2cec82c28802da31596b395ad292cb8f132fd63 Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Mon, 25 Jul 2016 10:42:58 +0800 Subject: [PATCH 06/46] power: sbs-battery: Request threaded irq and fix dev callback cookie Currently the battery detect gpio can not be used with a chained interrupt controller that requires threaded irq handlers. Use threaded irq instead. In addition this was not going to be working at present because chip->power_supply is assigned after the request irq call. Signed-off-by: Phil Reid Signed-off-by: Sebastian Reichel --- drivers/power/supply/sbs-battery.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index 20f3be6f5b9a..f9012ed29f47 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -162,7 +162,6 @@ struct sbs_info { bool is_present; bool gpio_detect; bool enable_detection; - int irq; int last_state; int poll_time; struct delayed_work work; @@ -661,7 +660,8 @@ done: static irqreturn_t sbs_irq(int irq, void *devid) { - struct power_supply *battery = devid; + struct sbs_info *chip = devid; + struct power_supply *battery = chip->power_supply; power_supply_changed(battery); @@ -869,9 +869,9 @@ static int sbs_probe(struct i2c_client *client, goto skip_gpio; } - rc = request_irq(irq, sbs_irq, + rc = devm_request_threaded_irq(&client->dev, irq, NULL, sbs_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - dev_name(&client->dev), chip->power_supply); + dev_name(&client->dev), chip); if (rc) { dev_warn(&client->dev, "Failed to request irq: %d\n", rc); gpio_free(pdata->battery_detect); @@ -879,8 +879,6 @@ static int sbs_probe(struct i2c_client *client, goto skip_gpio; } - chip->irq = irq; - skip_gpio: /* * Before we register, we might need to make sure we can actually talk @@ -915,8 +913,6 @@ skip_gpio: return 0; exit_psupply: - if (chip->irq) - free_irq(chip->irq, chip->power_supply); if (chip->gpio_detect) gpio_free(pdata->battery_detect); @@ -927,8 +923,6 @@ static int sbs_remove(struct i2c_client *client) { struct sbs_info *chip = i2c_get_clientdata(client); - if (chip->irq) - free_irq(chip->irq, chip->power_supply); if (chip->gpio_detect) gpio_free(chip->pdata->battery_detect); From 492ff9d8f5fa6ad44288050238b7961d457a239d Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Mon, 25 Jul 2016 10:42:59 +0800 Subject: [PATCH 07/46] power: sbs-battery: Use devm_power_supply_register Use devm_power_supply_register instead of power_supply_register. Remove call to power_supply_unregister. Signed-off-by: Phil Reid Signed-off-by: Sebastian Reichel --- drivers/power/supply/sbs-battery.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index f9012ed29f47..31f3e333b950 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -894,7 +894,7 @@ skip_gpio: } } - chip->power_supply = power_supply_register(&client->dev, sbs_desc, + chip->power_supply = devm_power_supply_register(&client->dev, sbs_desc, &psy_cfg); if (IS_ERR(chip->power_supply)) { dev_err(&client->dev, @@ -926,8 +926,6 @@ static int sbs_remove(struct i2c_client *client) if (chip->gpio_detect) gpio_free(chip->pdata->battery_detect); - power_supply_unregister(chip->power_supply); - cancel_delayed_work_sync(&chip->work); return 0; From 957cb720518341abf19009044f240a6342bdd039 Mon Sep 17 00:00:00 2001 From: Joshua Clayton Date: Thu, 11 Aug 2016 09:59:12 -0700 Subject: [PATCH 08/46] sbs-battery: add ability to get battery capacity Battery capacity level is a standard feature of sbs battery That can be used to tell what the remainig battery capacity is, and can tell if the battery has not been calibrated/initialized, which makes the capacity and charging/discharging percentages invalid. Signed-off-by: Joshua Clayton Signed-off-by: Sebastian Reichel --- drivers/power/supply/sbs-battery.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index 31f3e333b950..e1dfb3e7aee4 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -41,6 +41,7 @@ enum { REG_TIME_TO_EMPTY, REG_TIME_TO_FULL, REG_STATUS, + REG_CAPACITY_LEVEL, REG_CYCLE_COUNT, REG_SERIAL_NUMBER, REG_REMAINING_CAPACITY, @@ -68,6 +69,7 @@ enum sbs_battery_mode { #define MANUFACTURER_ACCESS_SLEEP 0x0011 /* battery status value bits */ +#define BATTERY_INITIALIZED 0x80 #define BATTERY_DISCHARGING 0x40 #define BATTERY_FULL_CHARGED 0x20 #define BATTERY_FULL_DISCHARGED 0x10 @@ -110,6 +112,8 @@ static const struct chip_data { SBS_DATA(POWER_SUPPLY_PROP_TIME_TO_FULL_AVG, 0x13, 0, 65535), [REG_STATUS] = SBS_DATA(POWER_SUPPLY_PROP_STATUS, 0x16, 0, 65535), + [REG_CAPACITY_LEVEL] = + SBS_DATA(POWER_SUPPLY_PROP_CAPACITY_LEVEL, 0x16, 0, 65535), [REG_CYCLE_COUNT] = SBS_DATA(POWER_SUPPLY_PROP_CYCLE_COUNT, 0x17, 0, 65535), [REG_DESIGN_CAPACITY] = @@ -131,6 +135,7 @@ static const struct chip_data { static enum power_supply_property sbs_properties[] = { POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_CAPACITY_LEVEL, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -376,8 +381,23 @@ static int sbs_get_battery_property(struct i2c_client *client, if (ret >= sbs_data[reg_offset].min_value && ret <= sbs_data[reg_offset].max_value) { val->intval = ret; - if (psp != POWER_SUPPLY_PROP_STATUS) + if (psp == POWER_SUPPLY_PROP_CAPACITY_LEVEL) { + if (!(ret & BATTERY_INITIALIZED)) + val->intval = + POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; + else if (ret & BATTERY_FULL_CHARGED) + val->intval = + POWER_SUPPLY_CAPACITY_LEVEL_FULL; + else if (ret & BATTERY_FULL_DISCHARGED) + val->intval = + POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL; + else + val->intval = + POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; return 0; + } else if (psp != POWER_SUPPLY_PROP_STATUS) { + return 0; + } if (ret & BATTERY_FULL_CHARGED) val->intval = POWER_SUPPLY_STATUS_FULL; @@ -589,6 +609,7 @@ static int sbs_get_property(struct power_supply *psy, break; case POWER_SUPPLY_PROP_STATUS: + case POWER_SUPPLY_PROP_CAPACITY_LEVEL: case POWER_SUPPLY_PROP_CYCLE_COUNT: case POWER_SUPPLY_PROP_VOLTAGE_NOW: case POWER_SUPPLY_PROP_CURRENT_NOW: From c1a9634f1aaf5e10c23f8890ea2e64c61d48cb44 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Wed, 3 Aug 2016 22:04:05 -0700 Subject: [PATCH 09/46] power: reset: reboot-mode: Add managed resource API Provide managed resource version of reboot_mode_register() and reboot_mode_unregister() to simplify implementations. Signed-off-by: Bjorn Andersson Tested-by: John Stultz Signed-off-by: Sebastian Reichel --- Documentation/driver-model/devres.txt | 4 ++ drivers/power/reset/reboot-mode.c | 59 +++++++++++++++++++++++++++ drivers/power/reset/reboot-mode.h | 4 ++ 3 files changed, 67 insertions(+) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index b0d775d28e97..b1ff0b7edb45 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -342,6 +342,10 @@ PINCTRL devm_pinctrl_register() devm_pinctrl_unregister() +POWER + devm_reboot_mode_register() + devm_reboot_mode_unregister() + PWM devm_pwm_get() devm_pwm_put() diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c index 2dfbbce0f817..fb512183ace3 100644 --- a/drivers/power/reset/reboot-mode.c +++ b/drivers/power/reset/reboot-mode.c @@ -135,6 +135,65 @@ int reboot_mode_unregister(struct reboot_mode_driver *reboot) } EXPORT_SYMBOL_GPL(reboot_mode_unregister); +static void devm_reboot_mode_release(struct device *dev, void *res) +{ + reboot_mode_unregister(*(struct reboot_mode_driver **)res); +} + +/** + * devm_reboot_mode_register() - resource managed reboot_mode_register() + * @dev: device to associate this resource with + * @reboot: reboot mode driver + * + * Returns: 0 on success or a negative error code on failure. + */ +int devm_reboot_mode_register(struct device *dev, + struct reboot_mode_driver *reboot) +{ + struct reboot_mode_driver **dr; + int rc; + + dr = devres_alloc(devm_reboot_mode_release, sizeof(*dr), GFP_KERNEL); + if (!dr) + return -ENOMEM; + + rc = reboot_mode_register(reboot); + if (rc) { + devres_free(dr); + return rc; + } + + *dr = reboot; + devres_add(dev, dr); + + return 0; +} +EXPORT_SYMBOL_GPL(devm_reboot_mode_register); + +static int devm_reboot_mode_match(struct device *dev, void *res, void *data) +{ + struct reboot_mode_driver **p = res; + + if (WARN_ON(!p || !*p)) + return 0; + + return *p == data; +} + +/** + * devm_reboot_mode_unregister() - resource managed reboot_mode_unregister() + * @dev: device to associate this resource with + * @reboot: reboot mode driver + */ +void devm_reboot_mode_unregister(struct device *dev, + struct reboot_mode_driver *reboot) +{ + WARN_ON(devres_release(dev, + devm_reboot_mode_release, + devm_reboot_mode_match, reboot)); +} +EXPORT_SYMBOL_GPL(devm_reboot_mode_unregister); + MODULE_AUTHOR("Andy Yan Date: Wed, 3 Aug 2016 22:04:06 -0700 Subject: [PATCH 10/46] power: reset: syscon-reboot-mode: Use managed resource API Use the managed resource version of reboot_mode_register(). Signed-off-by: Bjorn Andersson Tested-by: John Stultz Signed-off-by: Sebastian Reichel --- drivers/power/reset/syscon-reboot-mode.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/power/reset/syscon-reboot-mode.c b/drivers/power/reset/syscon-reboot-mode.c index 9e1cba5dd58e..1ecb51d67149 100644 --- a/drivers/power/reset/syscon-reboot-mode.c +++ b/drivers/power/reset/syscon-reboot-mode.c @@ -53,8 +53,6 @@ static int syscon_reboot_mode_probe(struct platform_device *pdev) syscon_rbm->reboot.write = syscon_reboot_mode_write; syscon_rbm->mask = 0xffffffff; - dev_set_drvdata(&pdev->dev, syscon_rbm); - syscon_rbm->map = syscon_node_to_regmap(pdev->dev.parent->of_node); if (IS_ERR(syscon_rbm->map)) return PTR_ERR(syscon_rbm->map); @@ -65,20 +63,13 @@ static int syscon_reboot_mode_probe(struct platform_device *pdev) of_property_read_u32(pdev->dev.of_node, "mask", &syscon_rbm->mask); - ret = reboot_mode_register(&syscon_rbm->reboot); + ret = devm_reboot_mode_register(&pdev->dev, &syscon_rbm->reboot); if (ret) dev_err(&pdev->dev, "can't register reboot mode\n"); return ret; } -static int syscon_reboot_mode_remove(struct platform_device *pdev) -{ - struct syscon_reboot_mode *syscon_rbm = dev_get_drvdata(&pdev->dev); - - return reboot_mode_unregister(&syscon_rbm->reboot); -} - static const struct of_device_id syscon_reboot_mode_of_match[] = { { .compatible = "syscon-reboot-mode" }, {} @@ -86,7 +77,6 @@ static const struct of_device_id syscon_reboot_mode_of_match[] = { static struct platform_driver syscon_reboot_mode_driver = { .probe = syscon_reboot_mode_probe, - .remove = syscon_reboot_mode_remove, .driver = { .name = "syscon-reboot-mode", .of_match_table = syscon_reboot_mode_of_match, From 1bbd3d282557cf5e544cc749d577bd7cefe929f4 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Sat, 13 Aug 2016 09:06:22 +0000 Subject: [PATCH 11/46] power: z2_battery: remove .owner field for driver Remove .owner field if calls are used which set it automatically. Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci Signed-off-by: Wei Yongjun Signed-off-by: Sebastian Reichel --- drivers/power/supply/z2_battery.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/power/supply/z2_battery.c b/drivers/power/supply/z2_battery.c index b201e3facf73..8a43b49cfd35 100644 --- a/drivers/power/supply/z2_battery.c +++ b/drivers/power/supply/z2_battery.c @@ -317,7 +317,6 @@ MODULE_DEVICE_TABLE(i2c, z2_batt_id); static struct i2c_driver z2_batt_driver = { .driver = { .name = "z2-battery", - .owner = THIS_MODULE, .pm = Z2_BATTERY_PM_OPS }, .probe = z2_batt_probe, From ad7656c75faebb43cf1102756c503668309d666f Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Sat, 13 Aug 2016 09:06:47 +0000 Subject: [PATCH 12/46] power: axp288_fuel_gauge: remove duplicated include from axp288_fuel_gauge.c Remove duplicated include. Signed-off-by: Wei Yongjun Acked-by: Chen-Yu Tsai Signed-off-by: Sebastian Reichel --- drivers/power/supply/axp288_fuel_gauge.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c index 50c0110d6b58..5bdde692f724 100644 --- a/drivers/power/supply/axp288_fuel_gauge.c +++ b/drivers/power/supply/axp288_fuel_gauge.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include From 2ee565c934b7aa3ad84dcc3735fb2359026866a0 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Sat, 13 Aug 2016 09:07:07 +0000 Subject: [PATCH 13/46] power: axp288_charger: remove duplicated include from axp288_charger.c Remove duplicated include. Signed-off-by: Wei Yongjun Acked-by: Chen-Yu Tsai Signed-off-by: Sebastian Reichel --- drivers/power/supply/axp288_charger.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c index 4030eeb7cf65..75b8e0c7402b 100644 --- a/drivers/power/supply/axp288_charger.c +++ b/drivers/power/supply/axp288_charger.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include From 0b9992f76f65532be8727977bd6997aa55e1340e Mon Sep 17 00:00:00 2001 From: Bhaktipriya Shridhar Date: Sat, 13 Aug 2016 21:46:10 +0530 Subject: [PATCH 14/46] power: abx500_chargalg: Remove deprecated create_singlethread_workqueue alloc_ordered_workqueue() with WQ_MEM_RECLAIM set replaces deprecated create_singlethread_workqueue(). This is the identity conversion. The workqueue "chargalg_wq" is used for running the charging algorithm. It has multiple workitems viz &di->chargalg_periodic_work, &di->chargalg_wd_work, &di->chargalg_work per abx500_chargalg, which require ordering. It has been identity converted. Also, WQ_MEM_RECLAIM has been set to ensure forward progress under memory pressure. Signed-off-by: Bhaktipriya Shridhar Signed-off-by: Sebastian Reichel --- drivers/power/supply/abx500_chargalg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/abx500_chargalg.c b/drivers/power/supply/abx500_chargalg.c index d9104b1ab7cf..a4411d6bbc96 100644 --- a/drivers/power/supply/abx500_chargalg.c +++ b/drivers/power/supply/abx500_chargalg.c @@ -2091,8 +2091,8 @@ static int abx500_chargalg_probe(struct platform_device *pdev) abx500_chargalg_maintenance_timer_expired; /* Create a work queue for the chargalg */ - di->chargalg_wq = - create_singlethread_workqueue("abx500_chargalg_wq"); + di->chargalg_wq = alloc_ordered_workqueue("abx500_chargalg_wq", + WQ_MEM_RECLAIM); if (di->chargalg_wq == NULL) { dev_err(di->dev, "failed to create work queue\n"); return -ENOMEM; From a8dd5b6868dd8ecb79f741dd94ac25a46ac19ba4 Mon Sep 17 00:00:00 2001 From: Bhaktipriya Shridhar Date: Sat, 13 Aug 2016 21:47:35 +0530 Subject: [PATCH 15/46] power: ab8500_btemp: Remove deprecated create_singlethread_workqueue The workqueue "btemp_wq" is used for measuring the temperature periodically. It queues a single workitem (btemp_periodic_work) and hence doesn't require ordering. Thus, the deprecated create_singlethread_workqueue() instance has been replaced with alloc_workqueue(). The WQ_MEM_RECLAIM flag has been set to ensure forward progress under memory pressure. Since there is a single work item, explicit concurrency limit is unnecessary here. Signed-off-by: Bhaktipriya Shridhar Signed-off-by: Sebastian Reichel --- drivers/power/supply/ab8500_btemp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c index bf2e5dd301e7..6ffdc18f2599 100644 --- a/drivers/power/supply/ab8500_btemp.c +++ b/drivers/power/supply/ab8500_btemp.c @@ -1095,7 +1095,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev) /* Create a work queue for the btemp */ di->btemp_wq = - create_singlethread_workqueue("ab8500_btemp_wq"); + alloc_workqueue("ab8500_btemp_wq", WQ_MEM_RECLAIM, 0); if (di->btemp_wq == NULL) { dev_err(di->dev, "failed to create work queue\n"); return -ENOMEM; From d8a69251fb58a756e2dd00cc5c7f1b54d383e203 Mon Sep 17 00:00:00 2001 From: Bhaktipriya Shridhar Date: Sat, 13 Aug 2016 21:48:43 +0530 Subject: [PATCH 16/46] power: pm2301_charger: Remove deprecated create_singlethread_workqueue alloc_ordered_workqueue() with WQ_MEM_RECLAIM set replaces deprecated create_singlethread_workqueue(). This is the identity conversion. The workqueue "charger_wq" is used for running all the charger related tasks. This involves charger detection, checking for HW failure and HW status. This workqueue has been identity converted. It queues multiple workitems viz &pm2->check_main_thermal_prot_work, &pm2->check_hw_failure_work, &pm2->ac_work. Hence, the deprecated create_singlethread_workqueue() instance has been replaced with a dedicated ordered workqueue. The WQ_MEM_RECLAIM flag has been set to ensure forward progress under memory pressure. Signed-off-by: Bhaktipriya Shridhar Signed-off-by: Sebastian Reichel --- drivers/power/supply/pm2301_charger.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/pm2301_charger.c b/drivers/power/supply/pm2301_charger.c index fb62ed3fc38c..78561b6884fc 100644 --- a/drivers/power/supply/pm2301_charger.c +++ b/drivers/power/supply/pm2301_charger.c @@ -1054,7 +1054,8 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client, pm2->ac_chg.external = true; /* Create a work queue for the charger */ - pm2->charger_wq = create_singlethread_workqueue("pm2xxx_charger_wq"); + pm2->charger_wq = alloc_ordered_workqueue("pm2xxx_charger_wq", + WQ_MEM_RECLAIM); if (pm2->charger_wq == NULL) { ret = -ENOMEM; dev_err(pm2->dev, "failed to create work queue\n"); From 87f818b35c3007d1014541c07688ab29443a22c2 Mon Sep 17 00:00:00 2001 From: Bhaktipriya Shridhar Date: Sat, 13 Aug 2016 21:50:11 +0530 Subject: [PATCH 17/46] power: intel_mid_battery: Remove deprecated create_singlethread_workqueue The workqueue "monitor_wqueue" is used to monitor the PMIC battery status. It queues a single work item (pbi->monitor_battery) and hence doesn't require ordering. Hence, alloc_workqueue has been used to replace the deprecated create_singlethread_workqueue instance. Since PMIC battery status needs to be monitored for any change, the WQ_MEM_RECLAIM flag has been set to ensure forward progress under memory pressure. Since there is a single work item, explicit concurrency limit is unnecessary here. Signed-off-by: Bhaktipriya Shridhar Signed-off-by: Sebastian Reichel --- drivers/power/supply/intel_mid_battery.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/power/supply/intel_mid_battery.c b/drivers/power/supply/intel_mid_battery.c index 9fa4acc107ca..dc7feef1bea4 100644 --- a/drivers/power/supply/intel_mid_battery.c +++ b/drivers/power/supply/intel_mid_battery.c @@ -689,8 +689,7 @@ static int probe(int irq, struct device *dev) /* initialize all required framework before enabling interrupts */ INIT_WORK(&pbi->handler, pmic_battery_handle_intrpt); INIT_DELAYED_WORK(&pbi->monitor_battery, pmic_battery_monitor); - pbi->monitor_wqueue = - create_singlethread_workqueue(dev_name(dev)); + pbi->monitor_wqueue = alloc_workqueue(dev_name(dev), WQ_MEM_RECLAIM, 0); if (!pbi->monitor_wqueue) { dev_err(dev, "%s(): wqueue init failed\n", __func__); retval = -ESRCH; From 9df82628265857e1c491c1ca0ace353e658457ea Mon Sep 17 00:00:00 2001 From: Bhaktipriya Shridhar Date: Sat, 13 Aug 2016 21:51:23 +0530 Subject: [PATCH 18/46] power: ab8500_charger: Remove deprecated create_singlethread_workqueue alloc_ordered_workqueue() with WQ_MEM_RECLAIM set replaces deprecated create_singlethread_workqueue(). This is the identity conversion. The workqueue "charger_wq" is used for the IRQs and checking HW state of the charger. It has been identity converted. It has multiple work items viz usb_charger_attached_work, kick_wd_work, check_vbat_work, check_hw_failure_work, usb_charger_attached_work, ac_work, ac_charger_attached_work, attach_work and check_usbchgnotok_work, which require execution ordering. Hence, a dedicated ordered workqueue has been used here. The WQ_MEM_RECLAIM flag has also been set to ensure forward progress under memory pressure. Signed-off-by: Bhaktipriya Shridhar Signed-off-by: Sebastian Reichel --- drivers/power/supply/ab8500_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index 30de5d42b26a..5cee9aa87aa3 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -3540,8 +3540,8 @@ static int ab8500_charger_probe(struct platform_device *pdev) di->usb_state.usb_current = -1; /* Create a work queue for the charger */ - di->charger_wq = - create_singlethread_workqueue("ab8500_charger_wq"); + di->charger_wq = alloc_ordered_workqueue("ab8500_charger_wq", + WQ_MEM_RECLAIM); if (di->charger_wq == NULL) { dev_err(di->dev, "failed to create work queue\n"); return -ENOMEM; From 829f0e97cc03b0c834cc5f86ff72b2ec389020ef Mon Sep 17 00:00:00 2001 From: Bhaktipriya Shridhar Date: Sat, 13 Aug 2016 22:03:53 +0530 Subject: [PATCH 19/46] power: ipaq_micro_battery: Remove deprecated create_singlethread_workqueue The workqueue "wq" is used for handling battery related tasks. It has a single work item viz &mb->update and hence it doesn't require execution ordering. Hence, alloc_workqueue has been used to replace the deprecated create_singlethread_workqueue instance. The WQ_MEM_RECLAIM flag has been set to ensure forward progress under memory pressure. Since there is a single work item, explicit concurrency limit is unnecessary here. Signed-off-by: Bhaktipriya Shridhar Signed-off-by: Sebastian Reichel --- drivers/power/supply/ipaq_micro_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/ipaq_micro_battery.c b/drivers/power/supply/ipaq_micro_battery.c index 35b01c7d775b..4af7b770f293 100644 --- a/drivers/power/supply/ipaq_micro_battery.c +++ b/drivers/power/supply/ipaq_micro_battery.c @@ -235,7 +235,7 @@ static int micro_batt_probe(struct platform_device *pdev) return -ENOMEM; mb->micro = dev_get_drvdata(pdev->dev.parent); - mb->wq = create_singlethread_workqueue("ipaq-battery-wq"); + mb->wq = alloc_workqueue("ipaq-battery-wq", WQ_MEM_RECLAIM, 0); if (!mb->wq) return -ENOMEM; From 1c53f3709cbc0da9fbf83bb10b2e3633ade05875 Mon Sep 17 00:00:00 2001 From: Bhaktipriya Shridhar Date: Sat, 13 Aug 2016 22:05:00 +0530 Subject: [PATCH 20/46] power: ab8500_fg: Remove deprecated create_singlethread_workqueue alloc_ordered_workqueue() with WQ_MEM_RECLAIM set replaces deprecated create_singlethread_workqueue(). This is the identity conversion. The workqueue "fg_wq" is used for running the FG algorithm periodically. It has been identity converted. It has multiple work items viz fg_periodic_work, fg_low_bat_work, fg_reinit_work, fg_work, fg_acc_cur_work and fg_check_hw_failure_work, which require execution ordering. Hence, a dedicated ordered workqueue has been used here. The WQ_MEM_RECLAIM flag has been set to guarantee forward progress under memory pressure. Signed-off-by: Bhaktipriya Shridhar Signed-off-by: Sebastian Reichel --- drivers/power/supply/ab8500_fg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 5a36cf88578a..199f2dbb0044 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -3096,7 +3096,7 @@ static int ab8500_fg_probe(struct platform_device *pdev) ab8500_fg_discharge_state_to(di, AB8500_FG_DISCHARGE_INIT); /* Create a work queue for running the FG algorithm */ - di->fg_wq = create_singlethread_workqueue("ab8500_fg_wq"); + di->fg_wq = alloc_ordered_workqueue("ab8500_fg_wq", WQ_MEM_RECLAIM); if (di->fg_wq == NULL) { dev_err(di->dev, "failed to create work queue\n"); return -ENOMEM; From b732ace40a1d5ea643ee9c28116e829ae950fe8f Mon Sep 17 00:00:00 2001 From: Bhaktipriya Shridhar Date: Sat, 13 Aug 2016 22:06:33 +0530 Subject: [PATCH 21/46] power: ds2760_battery: Remove deprecated create_singlethread_workqueue alloc_ordered_workqueue() with WQ_MEM_RECLAIM set replaces deprecated create_singlethread_workqueue(). This is the identity conversion. The workqueue "monitor_wqueue" is used to monitor the battery status. It has been identity converted. It queues multiple work items viz &di->monitor_work, &di->set_charged_work, which require execution ordering. Hence, alloc_workqueue has been used to replace the deprecated create_singlethread_workqueue instance. WQ_MEM_RECLAIM flag has been set to ensure forward progress under memory pressure. Signed-off-by: Bhaktipriya Shridhar Signed-off-by: Sebastian Reichel --- drivers/power/supply/ds2760_battery.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/ds2760_battery.c b/drivers/power/supply/ds2760_battery.c index 369ab00bf453..17225689e3f6 100644 --- a/drivers/power/supply/ds2760_battery.c +++ b/drivers/power/supply/ds2760_battery.c @@ -566,7 +566,8 @@ static int ds2760_battery_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&di->monitor_work, ds2760_battery_work); INIT_DELAYED_WORK(&di->set_charged_work, ds2760_battery_set_charged_work); - di->monitor_wqueue = create_singlethread_workqueue(dev_name(&pdev->dev)); + di->monitor_wqueue = alloc_ordered_workqueue(dev_name(&pdev->dev), + WQ_MEM_RECLAIM); if (!di->monitor_wqueue) { retval = -ESRCH; goto workqueue_failed; From 1c4593edbd4a893691fa826c36e71946a5d54c1d Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Wed, 17 Aug 2016 14:07:43 +0200 Subject: [PATCH 22/46] power: supply: Change Krzysztof Kozlowski's email to kernel.org Change my email address to kernel.org instead of Samsung one for the purpose of any future contact. The copyrights remain untouched and are attributed to Samsung. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sebastian Reichel --- Documentation/ABI/testing/sysfs-class-power | 8 ++++---- drivers/power/supply/max14577_charger.c | 4 ++-- drivers/power/supply/max77693_charger.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index fa05719f9981..f85ce9e327b9 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -22,7 +22,7 @@ Description: What: /sys/class/power_supply/max14577-charger/device/fast_charge_timer Date: October 2014 KernelVersion: 3.18.0 -Contact: Krzysztof Kozlowski +Contact: Krzysztof Kozlowski Description: This entry shows and sets the maximum time the max14577 charger operates in fast-charge mode. When the timer expires @@ -36,7 +36,7 @@ Description: What: /sys/class/power_supply/max77693-charger/device/fast_charge_timer Date: January 2015 KernelVersion: 3.19.0 -Contact: Krzysztof Kozlowski +Contact: Krzysztof Kozlowski Description: This entry shows and sets the maximum time the max77693 charger operates in fast-charge mode. When the timer expires @@ -50,7 +50,7 @@ Description: What: /sys/class/power_supply/max77693-charger/device/top_off_threshold_current Date: January 2015 KernelVersion: 3.19.0 -Contact: Krzysztof Kozlowski +Contact: Krzysztof Kozlowski Description: This entry shows and sets the charging current threshold for entering top-off charging mode. When charging current in fast @@ -65,7 +65,7 @@ Description: What: /sys/class/power_supply/max77693-charger/device/top_off_timer Date: January 2015 KernelVersion: 3.19.0 -Contact: Krzysztof Kozlowski +Contact: Krzysztof Kozlowski Description: This entry shows and sets the maximum time the max77693 charger operates in top-off charge mode. When the timer expires diff --git a/drivers/power/supply/max14577_charger.c b/drivers/power/supply/max14577_charger.c index a36bcaf62dd4..449fc56f09eb 100644 --- a/drivers/power/supply/max14577_charger.c +++ b/drivers/power/supply/max14577_charger.c @@ -2,7 +2,7 @@ * max14577_charger.c - Battery charger driver for the Maxim 14577/77836 * * Copyright (C) 2013,2014 Samsung Electronics - * Krzysztof Kozlowski + * Krzysztof Kozlowski * * 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 @@ -643,6 +643,6 @@ static struct platform_driver max14577_charger_driver = { }; module_platform_driver(max14577_charger_driver); -MODULE_AUTHOR("Krzysztof Kozlowski "); +MODULE_AUTHOR("Krzysztof Kozlowski "); MODULE_DESCRIPTION("Maxim 14577/77836 charger driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 060cab5ae3aa..6c78884bad5e 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -2,7 +2,7 @@ * max77693_charger.c - Battery charger driver for the Maxim 77693 * * Copyright (C) 2014 Samsung Electronics - * Krzysztof Kozlowski + * Krzysztof Kozlowski * * 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 @@ -766,6 +766,6 @@ static struct platform_driver max77693_charger_driver = { }; module_platform_driver(max77693_charger_driver); -MODULE_AUTHOR("Krzysztof Kozlowski "); +MODULE_AUTHOR("Krzysztof Kozlowski "); MODULE_DESCRIPTION("Maxim 77693 charger driver"); MODULE_LICENSE("GPL"); From ae0f74be6e3db97b23f33be2219044576525176a Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Sun, 28 Aug 2016 19:34:46 +0200 Subject: [PATCH 23/46] power: bq24735-charger: Assume not charging when charger is missing When the charger is missing (disconnected), it is safe to assume that the charger chip is no charging. This is especially relevant when a status GPIO is present and the charger is getting disconnected. bq24735_charger_is_charging will be triggered due to the interrupt then, it will attempt to read whether it is charging through i2c, which will fail as the charger is disconnected. This also fixes that specific issue. Signed-off-by: Paul Kocialkowski Signed-off-by: Sebastian Reichel --- drivers/power/supply/bq24735-charger.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/bq24735-charger.c b/drivers/power/supply/bq24735-charger.c index fa454c19ce17..dc460bb03d84 100644 --- a/drivers/power/supply/bq24735-charger.c +++ b/drivers/power/supply/bq24735-charger.c @@ -201,8 +201,12 @@ static bool bq24735_charger_is_present(struct bq24735 *charger) static int bq24735_charger_is_charging(struct bq24735 *charger) { - int ret = bq24735_read_word(charger->client, BQ24735_CHG_OPT); + int ret; + if (!bq24735_charger_is_present(charger)) + return 0; + + ret = bq24735_read_word(charger->client, BQ24735_CHG_OPT); if (ret < 0) return ret; From 58db95056759f2d9e4a41cb3d26007561a801135 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Wed, 17 Aug 2016 14:23:05 +0200 Subject: [PATCH 24/46] MAINTAINERS: update power-supply git-tree When I took over the power-supply tree, its git tree was hosted on git.infradead.org. Since a few kernel releases I also maintain a copy of the repository on git.kernel.org, that is prefered by Linus, so let's switch over officially. Signed-off-By: Sebastian Reichel --- MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index c7d6762424a1..923b138836b9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9329,7 +9329,7 @@ M: Sebastian Reichel M: Dmitry Eremin-Solenikov M: David Woodhouse L: linux-pm@vger.kernel.org -T: git git://git.infradead.org/battery-2.6.git +T: git git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git S: Maintained F: Documentation/devicetree/bindings/power/supply/ F: include/linux/power_supply.h @@ -11332,7 +11332,7 @@ M: Sebastian Reichel M: Dmitry Eremin-Solenikov M: David Woodhouse L: linux-pm@vger.kernel.org -T: git git://git.infradead.org/battery-2.6.git +T: git git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git S: Maintained F: Documentation/devicetree/bindings/power/reset/ F: drivers/power/reset/ From 2fe921758f6ebbfd1df73bcf0a9af6a682cef2b5 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Wed, 17 Aug 2016 14:32:38 +0200 Subject: [PATCH 25/46] MAINTAINERS: Remove power-supply co-maintainers This documents the status quo and keeps everyones cc/to-list a bit shorter. Signed-off-by: Sebastian Reichel --- CREDITS | 4 ++++ MAINTAINERS | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CREDITS b/CREDITS index 2a3fbcd229e6..2cb28a39851d 100644 --- a/CREDITS +++ b/CREDITS @@ -1090,6 +1090,10 @@ S: 6350 Stoneridge Mall Road S: Pleasanton, CA 94588 S: USA +N: Dmitry Eremin-Solenikov +E: dbaryshkov@gmail.com +D: Power Supply Maintainer from v3.14 - v3.15 + N: Doug Evans E: dje@cygnus.com D: Wrote Xenix FS (part of standard kernel since 0.99.15) diff --git a/MAINTAINERS b/MAINTAINERS index 923b138836b9..9074e68baa47 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9326,8 +9326,6 @@ F: drivers/powercap/ POWER SUPPLY CLASS/SUBSYSTEM and DRIVERS M: Sebastian Reichel -M: Dmitry Eremin-Solenikov -M: David Woodhouse L: linux-pm@vger.kernel.org T: git git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git S: Maintained @@ -11329,8 +11327,6 @@ F: drivers/mfd/syscon.c SYSTEM RESET/SHUTDOWN DRIVERS M: Sebastian Reichel -M: Dmitry Eremin-Solenikov -M: David Woodhouse L: linux-pm@vger.kernel.org T: git git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git S: Maintained From 5da643b26d280e1b061e18b92bc7d5709ee8034e Mon Sep 17 00:00:00 2001 From: Wenyou Yang Date: Thu, 25 Aug 2016 15:19:50 +0800 Subject: [PATCH 26/46] power: supply: act8945a_charger: Achieve properties from its node Since the act8945a_charger is regarded as a sub-device, all properties will be assigned to its own device node. All properties can be achieved from its own node, instead of from its parent device. Signed-off-by: Wenyou Yang Signed-off-by: Sebastian Reichel --- drivers/power/supply/act8945a_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/act8945a_charger.c b/drivers/power/supply/act8945a_charger.c index b5c00e45741e..3f486c9362c8 100644 --- a/drivers/power/supply/act8945a_charger.c +++ b/drivers/power/supply/act8945a_charger.c @@ -328,11 +328,11 @@ static int act8945a_charger_probe(struct platform_device *pdev) return -EINVAL; } - ret = act8945a_charger_config(pdev->dev.parent, charger); + ret = act8945a_charger_config(&pdev->dev, charger); if (ret) return ret; - psy_cfg.of_node = pdev->dev.parent->of_node; + psy_cfg.of_node = pdev->dev.of_node; psy_cfg.drv_data = charger; psy = devm_power_supply_register(&pdev->dev, From 6b021fc91038201ed44e99ae32b6a93c6e8be1f4 Mon Sep 17 00:00:00 2001 From: Wenyou Yang Date: Thu, 25 Aug 2016 15:19:51 +0800 Subject: [PATCH 27/46] power: supply: act8945a_charger: Remove "battery_temperature" Remove "battery_temperature" member, it is redundant, it is the hardware's responsibility to handle TH pin properly. It is unnecessary to use the dt property to check if there is a battery temperature monitor or not. Signed-off-by: Wenyou Yang Signed-off-by: Sebastian Reichel --- drivers/power/supply/act8945a_charger.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/power/supply/act8945a_charger.c b/drivers/power/supply/act8945a_charger.c index 3f486c9362c8..af006680dd5c 100644 --- a/drivers/power/supply/act8945a_charger.c +++ b/drivers/power/supply/act8945a_charger.c @@ -76,7 +76,6 @@ static const char *act8945a_charger_manufacturer = "Active-semi"; struct act8945a_charger { struct regmap *regmap; - bool battery_temperature; }; static int act8945a_get_charger_state(struct regmap *regmap, int *val) @@ -138,8 +137,7 @@ static int act8945a_get_charge_type(struct regmap *regmap, int *val) return 0; } -static int act8945a_get_battery_health(struct act8945a_charger *charger, - struct regmap *regmap, int *val) +static int act8945a_get_battery_health(struct regmap *regmap, int *val) { int ret; unsigned int status; @@ -148,7 +146,7 @@ static int act8945a_get_battery_health(struct act8945a_charger *charger, if (ret < 0) return ret; - if (charger->battery_temperature && !(status & APCH_STATUS_TEMPDAT)) + if (!(status & APCH_STATUS_TEMPDAT)) *val = POWER_SUPPLY_HEALTH_OVERHEAT; else if (!(status & APCH_STATUS_INDAT)) *val = POWER_SUPPLY_HEALTH_OVERVOLTAGE; @@ -188,8 +186,7 @@ static int act8945a_charger_get_property(struct power_supply *psy, val->intval = POWER_SUPPLY_TECHNOLOGY_LION; break; case POWER_SUPPLY_PROP_HEALTH: - ret = act8945a_get_battery_health(charger, - regmap, &val->intval); + ret = act8945a_get_battery_health(regmap, &val->intval); break; case POWER_SUPPLY_PROP_MODEL_NAME: val->strval = act8945a_charger_model; @@ -235,9 +232,6 @@ static int act8945a_charger_config(struct device *dev, return -EINVAL; } - charger->battery_temperature = of_property_read_bool(np, - "active-semi,check-battery-temperature"); - chglev_pin = of_get_named_gpio_flags(np, "active-semi,chglev-gpios", 0, &flags); From 1f0ba4067af4bda55b7304e74fc20a245912b728 Mon Sep 17 00:00:00 2001 From: Wenyou Yang Date: Thu, 25 Aug 2016 15:19:52 +0800 Subject: [PATCH 28/46] power: supply: act8945a_charger: Improve state handling When get the property, first check the charger state machine, then check the status bit to decide what value is assigned to the corresponding property. Retain the SUSCHG bit of REG 0x71 when configure the timers to avoid losting the charger suspending info after boot. Signed-off-by: Wenyou Yang Signed-off-by: Fengguang Wu Signed-off-by: Sebastian Reichel --- drivers/power/supply/act8945a_charger.c | 86 ++++++++++++++++++++----- 1 file changed, 70 insertions(+), 16 deletions(-) diff --git a/drivers/power/supply/act8945a_charger.c b/drivers/power/supply/act8945a_charger.c index af006680dd5c..a6bbaff5483e 100644 --- a/drivers/power/supply/act8945a_charger.c +++ b/drivers/power/supply/act8945a_charger.c @@ -94,16 +94,24 @@ static int act8945a_get_charger_state(struct regmap *regmap, int *val) state &= APCH_STATE_CSTATE; state >>= APCH_STATE_CSTATE_SHIFT; - if (state == APCH_STATE_CSTATE_EOC) { + switch (state) { + case APCH_STATE_CSTATE_PRE: + case APCH_STATE_CSTATE_FAST: + *val = POWER_SUPPLY_STATUS_CHARGING; + break; + case APCH_STATE_CSTATE_EOC: if (status & APCH_STATUS_CHGDAT) *val = POWER_SUPPLY_STATUS_FULL; + else + *val = POWER_SUPPLY_STATUS_CHARGING; + break; + case APCH_STATE_CSTATE_DISABLED: + default: + if (!(status & APCH_STATUS_INDAT)) + *val = POWER_SUPPLY_STATUS_DISCHARGING; else *val = POWER_SUPPLY_STATUS_NOT_CHARGING; - } else if ((state == APCH_STATE_CSTATE_FAST) || - (state == APCH_STATE_CSTATE_PRE)) { - *val = POWER_SUPPLY_STATUS_CHARGING; - } else { - *val = POWER_SUPPLY_STATUS_NOT_CHARGING; + break; } return 0; @@ -112,7 +120,11 @@ static int act8945a_get_charger_state(struct regmap *regmap, int *val) static int act8945a_get_charge_type(struct regmap *regmap, int *val) { int ret; - unsigned int state; + unsigned int status, state; + + ret = regmap_read(regmap, ACT8945A_APCH_STATUS, &status); + if (ret < 0) + return ret; ret = regmap_read(regmap, ACT8945A_APCH_STATE, &state); if (ret < 0) @@ -129,9 +141,15 @@ static int act8945a_get_charge_type(struct regmap *regmap, int *val) *val = POWER_SUPPLY_CHARGE_TYPE_FAST; break; case APCH_STATE_CSTATE_EOC: + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + break; case APCH_STATE_CSTATE_DISABLED: default: - *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + if (!(status & APCH_STATUS_INDAT)) + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + else + *val = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN; + break; } return 0; @@ -140,20 +158,45 @@ static int act8945a_get_charge_type(struct regmap *regmap, int *val) static int act8945a_get_battery_health(struct regmap *regmap, int *val) { int ret; - unsigned int status; + unsigned int status, state, config; ret = regmap_read(regmap, ACT8945A_APCH_STATUS, &status); if (ret < 0) return ret; - if (!(status & APCH_STATUS_TEMPDAT)) - *val = POWER_SUPPLY_HEALTH_OVERHEAT; - else if (!(status & APCH_STATUS_INDAT)) - *val = POWER_SUPPLY_HEALTH_OVERVOLTAGE; - else if (status & APCH_STATUS_TIMRDAT) - *val = POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE; - else + ret = regmap_read(regmap, ACT8945A_APCH_CFG, &config); + if (ret < 0) + return ret; + + ret = regmap_read(regmap, ACT8945A_APCH_STATE, &state); + if (ret < 0) + return ret; + + state &= APCH_STATE_CSTATE; + state >>= APCH_STATE_CSTATE_SHIFT; + + switch (state) { + case APCH_STATE_CSTATE_DISABLED: + if (config & APCH_CFG_SUSCHG) { + *val = POWER_SUPPLY_HEALTH_UNKNOWN; + } else if (status & APCH_STATUS_INDAT) { + if (!(status & APCH_STATUS_TEMPDAT)) + *val = POWER_SUPPLY_HEALTH_OVERHEAT; + else if (status & APCH_STATUS_TIMRDAT) + *val = POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE; + else + *val = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + } else { + *val = POWER_SUPPLY_HEALTH_GOOD; + } + break; + case APCH_STATE_CSTATE_PRE: + case APCH_STATE_CSTATE_FAST: + case APCH_STATE_CSTATE_EOC: + default: *val = POWER_SUPPLY_HEALTH_GOOD; + break; + } return 0; } @@ -224,7 +267,9 @@ static int act8945a_charger_config(struct device *dev, u32 pre_time_out; u32 input_voltage_threshold; int chglev_pin; + int ret; + unsigned int tmp; unsigned int value = 0; if (!np) { @@ -232,6 +277,15 @@ static int act8945a_charger_config(struct device *dev, return -EINVAL; } + ret = regmap_read(regmap, ACT8945A_APCH_CFG, &tmp); + if (ret) + return ret; + + if (tmp & APCH_CFG_SUSCHG) { + value |= APCH_CFG_SUSCHG; + dev_info(dev, "have been suspended\n"); + } + chglev_pin = of_get_named_gpio_flags(np, "active-semi,chglev-gpios", 0, &flags); From a09209acd6a808794bdd7866af3678d1fd1d90e7 Mon Sep 17 00:00:00 2001 From: Wenyou Yang Date: Thu, 25 Aug 2016 15:19:53 +0800 Subject: [PATCH 29/46] power: supply: act8945a_charger: Add status change update support Add the charger status change interrupt support, it will report the power supply changed event. This interrupt is generated by one of the conditions as below: - the state machine jumps out of or into the EOC state - the CHGIN input voltage goes out of or into the valid range. - the battery temperature goes out of or into the valid range. - the PRECHARGE time-out occurs. - the total charge time-out occurs. Signed-off-by: Wenyou Yang Signed-off-by: Sebastian Reichel --- drivers/power/supply/act8945a_charger.c | 95 +++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 7 deletions(-) diff --git a/drivers/power/supply/act8945a_charger.c b/drivers/power/supply/act8945a_charger.c index a6bbaff5483e..e129255c1e0d 100644 --- a/drivers/power/supply/act8945a_charger.c +++ b/drivers/power/supply/act8945a_charger.c @@ -10,9 +10,11 @@ * published by the Free Software Foundation. * */ +#include #include #include #include +#include #include #include #include @@ -75,7 +77,11 @@ static const char *act8945a_charger_manufacturer = "Active-semi"; #define APCH_STATE_CSTATE_PRE 0x03 struct act8945a_charger { + struct power_supply *psy; struct regmap *regmap; + struct work_struct work; + + bool init_done; }; static int act8945a_get_charger_state(struct regmap *regmap, int *val) @@ -252,6 +258,47 @@ static const struct power_supply_desc act8945a_charger_desc = { .num_properties = ARRAY_SIZE(act8945a_charger_props), }; +static int act8945a_enable_interrupt(struct act8945a_charger *charger) +{ + struct regmap *regmap = charger->regmap; + unsigned char ctrl; + int ret; + + ctrl = APCH_CTRL_CHGEOCOUT | APCH_CTRL_CHGEOCIN | + APCH_CTRL_INDIS | APCH_CTRL_INCON | + APCH_CTRL_TEMPOUT | APCH_CTRL_TEMPIN | + APCH_CTRL_TIMRPRE | APCH_CTRL_TIMRTOT; + ret = regmap_write(regmap, ACT8945A_APCH_CTRL, ctrl); + if (ret) + return ret; + + ctrl = APCH_STATUS_CHGSTAT | APCH_STATUS_INSTAT | + APCH_STATUS_TEMPSTAT | APCH_STATUS_TIMRSTAT; + ret = regmap_write(regmap, ACT8945A_APCH_STATUS, ctrl); + if (ret) + return ret; + + return 0; +} + +static void act8945a_work(struct work_struct *work) +{ + struct act8945a_charger *charger = + container_of(work, struct act8945a_charger, work); + + power_supply_changed(charger->psy); +} + +static irqreturn_t act8945a_status_changed(int irq, void *dev_id) +{ + struct act8945a_charger *charger = dev_id; + + if (charger->init_done) + schedule_work(&charger->work); + + return IRQ_HANDLED; +} + #define DEFAULT_TOTAL_TIME_OUT 3 #define DEFAULT_PRE_TIME_OUT 40 #define DEFAULT_INPUT_OVP_THRESHOLD 6600 @@ -362,9 +409,8 @@ static int act8945a_charger_config(struct device *dev, static int act8945a_charger_probe(struct platform_device *pdev) { struct act8945a_charger *charger; - struct power_supply *psy; struct power_supply_config psy_cfg = {}; - int ret; + int irq, ret; charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL); if (!charger) @@ -380,17 +426,51 @@ static int act8945a_charger_probe(struct platform_device *pdev) if (ret) return ret; + irq = of_irq_get(pdev->dev.of_node, 0); + if (irq == -EPROBE_DEFER) { + dev_err(&pdev->dev, "failed to find IRQ number\n"); + return -EPROBE_DEFER; + } + + ret = devm_request_irq(&pdev->dev, irq, act8945a_status_changed, + IRQF_TRIGGER_FALLING, "act8945a_interrupt", + charger); + if (ret) { + dev_err(&pdev->dev, "failed to request nIRQ pin IRQ\n"); + return ret; + } + psy_cfg.of_node = pdev->dev.of_node; psy_cfg.drv_data = charger; - psy = devm_power_supply_register(&pdev->dev, - &act8945a_charger_desc, - &psy_cfg); - if (IS_ERR(psy)) { + charger->psy = devm_power_supply_register(&pdev->dev, + &act8945a_charger_desc, + &psy_cfg); + if (IS_ERR(charger->psy)) { dev_err(&pdev->dev, "failed to register power supply\n"); - return PTR_ERR(psy); + return PTR_ERR(charger->psy); } + platform_set_drvdata(pdev, charger); + + INIT_WORK(&charger->work, act8945a_work); + + ret = act8945a_enable_interrupt(charger); + if (ret) + return -EIO; + + charger->init_done = true; + + return 0; +} + +static int act8945a_charger_remove(struct platform_device *pdev) +{ + struct act8945a_charger *charger = platform_get_drvdata(pdev); + + charger->init_done = false; + cancel_work_sync(&charger->work); + return 0; } @@ -399,6 +479,7 @@ static struct platform_driver act8945a_charger_driver = { .name = "act8945a-charger", }, .probe = act8945a_charger_probe, + .remove = act8945a_charger_remove, }; module_platform_driver(act8945a_charger_driver); From 10ca08b07bc572ff39bd95148085994e9958b10b Mon Sep 17 00:00:00 2001 From: Wenyou Yang Date: Thu, 25 Aug 2016 15:19:54 +0800 Subject: [PATCH 30/46] power: supply: act8945a_charger: Fix the power supply type The power supply type property is varying as the external power supply changes. It is not a constant. Signed-off-by: Wenyou Yang Signed-off-by: Sebastian Reichel --- drivers/power/supply/act8945a_charger.c | 48 ++++++++++++++++++++----- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/drivers/power/supply/act8945a_charger.c b/drivers/power/supply/act8945a_charger.c index e129255c1e0d..48775f8233f3 100644 --- a/drivers/power/supply/act8945a_charger.c +++ b/drivers/power/supply/act8945a_charger.c @@ -78,6 +78,7 @@ static const char *act8945a_charger_manufacturer = "Active-semi"; struct act8945a_charger { struct power_supply *psy; + struct power_supply_desc desc; struct regmap *regmap; struct work_struct work; @@ -250,14 +251,6 @@ static int act8945a_charger_get_property(struct power_supply *psy, return ret; } -static const struct power_supply_desc act8945a_charger_desc = { - .name = "act8945a-charger", - .type = POWER_SUPPLY_TYPE_BATTERY, - .get_property = act8945a_charger_get_property, - .properties = act8945a_charger_props, - .num_properties = ARRAY_SIZE(act8945a_charger_props), -}; - static int act8945a_enable_interrupt(struct act8945a_charger *charger) { struct regmap *regmap = charger->regmap; @@ -281,11 +274,39 @@ static int act8945a_enable_interrupt(struct act8945a_charger *charger) return 0; } +static unsigned int act8945a_set_supply_type(struct act8945a_charger *charger, + unsigned int *type) +{ + unsigned int status, state; + int ret; + + ret = regmap_read(charger->regmap, ACT8945A_APCH_STATUS, &status); + if (ret < 0) + return ret; + + ret = regmap_read(charger->regmap, ACT8945A_APCH_STATE, &state); + if (ret < 0) + return ret; + + if (status & APCH_STATUS_INDAT) { + if (state & APCH_STATE_ACINSTAT) + *type = POWER_SUPPLY_TYPE_MAINS; + else + *type = POWER_SUPPLY_TYPE_USB; + } else { + *type = POWER_SUPPLY_TYPE_BATTERY; + } + + return 0; +} + static void act8945a_work(struct work_struct *work) { struct act8945a_charger *charger = container_of(work, struct act8945a_charger, work); + act8945a_set_supply_type(charger, &charger->desc.type); + power_supply_changed(charger->psy); } @@ -440,11 +461,20 @@ static int act8945a_charger_probe(struct platform_device *pdev) return ret; } + charger->desc.name = "act8945a-charger"; + charger->desc.get_property = act8945a_charger_get_property; + charger->desc.properties = act8945a_charger_props; + charger->desc.num_properties = ARRAY_SIZE(act8945a_charger_props); + + ret = act8945a_set_supply_type(charger, &charger->desc.type); + if (ret) + return -EINVAL; + psy_cfg.of_node = pdev->dev.of_node; psy_cfg.drv_data = charger; charger->psy = devm_power_supply_register(&pdev->dev, - &act8945a_charger_desc, + &charger->desc, &psy_cfg); if (IS_ERR(charger->psy)) { dev_err(&pdev->dev, "failed to register power supply\n"); From 30953650801a8c83fc96acdc032e0a0dbb018b07 Mon Sep 17 00:00:00 2001 From: Wenyou Yang Date: Thu, 25 Aug 2016 15:40:26 +0800 Subject: [PATCH 31/46] doc: bindings: power: act8945a-charger: Update properties. Due the driver improvements, update the properties, - Remove "active-semi,check-battery-temperature" property. - Add the properties, "active-semi,irq_gpio" and "active-semi,lbo-gpios". - As act8945a-charger is regarded as a sub-device, update the compatible and examples. Signed-off-by: Wenyou Yang Acked-by: Rob Herring Signed-off-by: Sebastian Reichel --- .../power/supply/act8945a-charger.txt | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Documentation/devicetree/bindings/power/supply/act8945a-charger.txt b/Documentation/devicetree/bindings/power/supply/act8945a-charger.txt index bea254c9d136..de78d761ce44 100644 --- a/Documentation/devicetree/bindings/power/supply/act8945a-charger.txt +++ b/Documentation/devicetree/bindings/power/supply/act8945a-charger.txt @@ -1,13 +1,18 @@ Device-Tree bindings for charger of Active-semi ACT8945A Multi-Function Device Required properties: - - compatible: "active-semi,act8945a", please refer to ../mfd/act8945a.txt. + - compatible: "active-semi,act8945a-charger". - active-semi,chglev-gpios: charge current level phandle with args as described in ../gpio/gpio.txt. + - active-semi,lbo-gpios: specify the low battery voltage detect phandle + with args as as described in ../gpio/gpio.txt. + - interrupts: where a is the interrupt number and b is a + field that represents an encoding of the sense and level + information for the interrupt. + - interrupt-parent: the phandle for the interrupt controller that + services interrupts for this device. Optional properties: - - active-semi,check-battery-temperature: boolean to check the battery - temperature or not. - active-semi,input-voltage-threshold-microvolt: unit: mV; Specifies the charger's input over-voltage threshold value; The value can be: 6600, 7000, 7500, 8000; default: 6600 @@ -26,10 +31,18 @@ Example: reg = <0x5b>; status = "okay"; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_charger_chglev>; - active-semi,chglev-gpios = <&pioA 12 GPIO_ACTIVE_HIGH>; - active-semi,input-voltage-threshold-microvolt = <6600>; - active-semi,precondition-timeout = <40>; - active-semi,total-timeout = <3>; + charger { + compatible = "active-semi,act8945a-charger"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_charger_chglev &pinctrl_charger_lbo &pinctrl_charger_irq>; + interrupt-parent = <&pioA>; + interrupts = <45 GPIO_ACTIVE_LOW>; + + active-semi,chglev-gpios = <&pioA 12 GPIO_ACTIVE_HIGH>; + active-semi,lbo-gpios = <&pioA 72 GPIO_ACTIVE_LOW>; + active-semi,input-voltage-threshold-microvolt = <6600>; + active-semi,precondition-timeout = <40>; + active-semi,total-timeout = <3>; + status = "okay"; + }; }; From 369eba0986d503302784f55f1020129bf802ae72 Mon Sep 17 00:00:00 2001 From: Wenyou Yang Date: Thu, 1 Sep 2016 17:29:58 +0800 Subject: [PATCH 32/46] power: supply: act8945a_charger: Add capacity level property Add the power supply capacity level property, it corresponds to POWER_SUPPLY_CAPACITY_LEVEL_*. It also utilizes the precision voltage detector function module to catch the low battery voltage. Signed-off-by: Wenyou Yang Signed-off-by: Sebastian Reichel --- drivers/power/supply/act8945a_charger.c | 79 ++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/act8945a_charger.c b/drivers/power/supply/act8945a_charger.c index 48775f8233f3..2f875997d97a 100644 --- a/drivers/power/supply/act8945a_charger.c +++ b/drivers/power/supply/act8945a_charger.c @@ -18,6 +18,7 @@ #include #include #include +#include static const char *act8945a_charger_model = "ACT8945A"; static const char *act8945a_charger_manufacturer = "Active-semi"; @@ -83,6 +84,7 @@ struct act8945a_charger { struct work_struct work; bool init_done; + struct gpio_desc *lbo_gpio; }; static int act8945a_get_charger_state(struct regmap *regmap, int *val) @@ -208,11 +210,67 @@ static int act8945a_get_battery_health(struct regmap *regmap, int *val) return 0; } +static int act8945a_get_capacity_level(struct act8945a_charger *charger, + struct regmap *regmap, int *val) +{ + int ret; + unsigned int status, state, config; + int lbo_level = gpiod_get_value(charger->lbo_gpio); + + ret = regmap_read(regmap, ACT8945A_APCH_STATUS, &status); + if (ret < 0) + return ret; + + ret = regmap_read(regmap, ACT8945A_APCH_CFG, &config); + if (ret < 0) + return ret; + + ret = regmap_read(regmap, ACT8945A_APCH_STATE, &state); + if (ret < 0) + return ret; + + state &= APCH_STATE_CSTATE; + state >>= APCH_STATE_CSTATE_SHIFT; + + switch (state) { + case APCH_STATE_CSTATE_PRE: + *val = POWER_SUPPLY_CAPACITY_LEVEL_LOW; + break; + case APCH_STATE_CSTATE_FAST: + if (lbo_level) + *val = POWER_SUPPLY_CAPACITY_LEVEL_HIGH; + else + *val = POWER_SUPPLY_CAPACITY_LEVEL_LOW; + break; + case APCH_STATE_CSTATE_EOC: + if (status & APCH_STATUS_CHGDAT) + *val = POWER_SUPPLY_CAPACITY_LEVEL_FULL; + else + *val = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; + break; + case APCH_STATE_CSTATE_DISABLED: + default: + if (config & APCH_CFG_SUSCHG) { + *val = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; + } else { + *val = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; + if (!(status & APCH_STATUS_INDAT)) { + if (!lbo_level) + *val = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL; + } + } + break; + } + + return 0; +} + static enum power_supply_property act8945a_charger_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_CHARGE_TYPE, POWER_SUPPLY_PROP_TECHNOLOGY, POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_PROP_CAPACITY_LEVEL, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER }; @@ -238,6 +296,10 @@ static int act8945a_charger_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_HEALTH: ret = act8945a_get_battery_health(regmap, &val->intval); break; + case POWER_SUPPLY_PROP_CAPACITY_LEVEL: + ret = act8945a_get_capacity_level(charger, + regmap, &val->intval); + break; case POWER_SUPPLY_PROP_MODEL_NAME: val->strval = act8945a_charger_model; break; @@ -335,7 +397,7 @@ static int act8945a_charger_config(struct device *dev, u32 pre_time_out; u32 input_voltage_threshold; int chglev_pin; - int ret; + int err, ret; unsigned int tmp; unsigned int value = 0; @@ -354,6 +416,21 @@ static int act8945a_charger_config(struct device *dev, dev_info(dev, "have been suspended\n"); } + charger->lbo_gpio = devm_gpiod_get_optional(dev, "active-semi,lbo", + GPIOD_IN); + if (IS_ERR(charger->lbo_gpio)) { + err = PTR_ERR(charger->lbo_gpio); + dev_err(dev, "unable to claim gpio \"lbo\": %d\n", err); + return err; + } + + ret = devm_request_irq(dev, gpiod_to_irq(charger->lbo_gpio), + act8945a_status_changed, + (IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING), + "act8945a_lbo_detect", charger); + if (ret) + dev_info(dev, "failed to request gpio \"lbo\" IRQ\n"); + chglev_pin = of_get_named_gpio_flags(np, "active-semi,chglev-gpios", 0, &flags); From 528e3504123d0281c613b83ca46aaf2dd7c3f45e Mon Sep 17 00:00:00 2001 From: Wenyou Yang Date: Thu, 1 Sep 2016 17:29:59 +0800 Subject: [PATCH 33/46] power: supply: act8945a_charger: Add max current property Add the power supply's current max property, POWER_SUPPLY_PROP_CURRENT_MAX. Signed-off-by: Wenyou Yang Signed-off-by: Sebastian Reichel --- drivers/power/supply/act8945a_charger.c | 89 ++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 9 deletions(-) diff --git a/drivers/power/supply/act8945a_charger.c b/drivers/power/supply/act8945a_charger.c index 2f875997d97a..d1eb2e359532 100644 --- a/drivers/power/supply/act8945a_charger.c +++ b/drivers/power/supply/act8945a_charger.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -85,6 +84,7 @@ struct act8945a_charger { bool init_done; struct gpio_desc *lbo_gpio; + struct gpio_desc *chglev_gpio; }; static int act8945a_get_charger_state(struct regmap *regmap, int *val) @@ -265,12 +265,80 @@ static int act8945a_get_capacity_level(struct act8945a_charger *charger, return 0; } +#define MAX_CURRENT_USB_HIGH 450000 +#define MAX_CURRENT_USB_LOW 90000 +#define MAX_CURRENT_USB_PRE 45000 +/* + * Riset(K) = 2336 * (1V/Ichg(mA)) - 0.205 + * Riset = 2.43K + */ +#define MAX_CURRENT_AC_HIGH 886527 +#define MAX_CURRENT_AC_LOW 117305 +#define MAX_CURRENT_AC_HIGH_PRE 88653 +#define MAX_CURRENT_AC_LOW_PRE 11731 + +static int act8945a_get_current_max(struct act8945a_charger *charger, + struct regmap *regmap, int *val) +{ + int ret; + unsigned int status, state; + unsigned int acin_state; + int chgin_level = gpiod_get_value(charger->chglev_gpio); + + ret = regmap_read(regmap, ACT8945A_APCH_STATUS, &status); + if (ret < 0) + return ret; + + ret = regmap_read(regmap, ACT8945A_APCH_STATE, &state); + if (ret < 0) + return ret; + + acin_state = (state & APCH_STATE_ACINSTAT) >> 1; + + state &= APCH_STATE_CSTATE; + state >>= APCH_STATE_CSTATE_SHIFT; + + switch (state) { + case APCH_STATE_CSTATE_PRE: + if (acin_state) { + if (chgin_level) + *val = MAX_CURRENT_AC_HIGH_PRE; + else + *val = MAX_CURRENT_AC_LOW_PRE; + } else { + *val = MAX_CURRENT_USB_PRE; + } + break; + case APCH_STATE_CSTATE_FAST: + if (acin_state) { + if (chgin_level) + *val = MAX_CURRENT_AC_HIGH; + else + *val = MAX_CURRENT_AC_LOW; + } else { + if (chgin_level) + *val = MAX_CURRENT_USB_HIGH; + else + *val = MAX_CURRENT_USB_LOW; + } + break; + case APCH_STATE_CSTATE_EOC: + case APCH_STATE_CSTATE_DISABLED: + default: + *val = 0; + break; + } + + return 0; +} + static enum power_supply_property act8945a_charger_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_CHARGE_TYPE, POWER_SUPPLY_PROP_TECHNOLOGY, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_CAPACITY_LEVEL, + POWER_SUPPLY_PROP_CURRENT_MAX, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER }; @@ -300,6 +368,10 @@ static int act8945a_charger_get_property(struct power_supply *psy, ret = act8945a_get_capacity_level(charger, regmap, &val->intval); break; + case POWER_SUPPLY_PROP_CURRENT_MAX: + ret = act8945a_get_current_max(charger, + regmap, &val->intval); + break; case POWER_SUPPLY_PROP_MODEL_NAME: val->strval = act8945a_charger_model; break; @@ -390,13 +462,11 @@ static int act8945a_charger_config(struct device *dev, struct act8945a_charger *charger) { struct device_node *np = dev->of_node; - enum of_gpio_flags flags; struct regmap *regmap = charger->regmap; u32 total_time_out; u32 pre_time_out; u32 input_voltage_threshold; - int chglev_pin; int err, ret; unsigned int tmp; @@ -431,12 +501,13 @@ static int act8945a_charger_config(struct device *dev, if (ret) dev_info(dev, "failed to request gpio \"lbo\" IRQ\n"); - chglev_pin = of_get_named_gpio_flags(np, - "active-semi,chglev-gpios", 0, &flags); - - if (gpio_is_valid(chglev_pin)) { - gpio_set_value(chglev_pin, - ((flags == OF_GPIO_ACTIVE_LOW) ? 0 : 1)); + charger->chglev_gpio = devm_gpiod_get_optional(dev, + "active-semi,chglev", + GPIOD_IN); + if (IS_ERR(charger->chglev_gpio)) { + err = PTR_ERR(charger->chglev_gpio); + dev_err(dev, "unable to claim gpio \"chglev\": %d\n", err); + return err; } if (of_property_read_u32(np, From 3b5dd3a49496220b35af83c96e3d2ff5716550ae Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Thu, 1 Sep 2016 15:50:52 +0800 Subject: [PATCH 34/46] power: supply: sbs-battery: Use gpio_desc and sleeping calls for battery detect Switch to using new gpio_desc interface and devm gpio get calls to automatically manage gpio resource. Use gpiod_get_value which handles active high / low calls. If gpio_detect is set then force loading of the driver as it is reasonable to assume that the battery may not be present. Update the is_present flag immediately in the IRQ. Remove legacy gpio specification from platform data. Signed-off-by: Phil Reid Signed-off-by: Sebastian Reichel --- drivers/power/supply/sbs-battery.c | 101 ++++++++++------------------- include/linux/power/sbs-battery.h | 4 -- 2 files changed, 34 insertions(+), 71 deletions(-) diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index e1dfb3e7aee4..8b4c6a8681b0 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -165,7 +165,7 @@ struct sbs_info { struct power_supply *power_supply; struct sbs_platform_data *pdata; bool is_present; - bool gpio_detect; + struct gpio_desc *gpio_detect; bool enable_detection; int last_state; int poll_time; @@ -306,13 +306,11 @@ static int sbs_get_battery_presence_and_health( s32 ret; struct sbs_info *chip = i2c_get_clientdata(client); - if (psp == POWER_SUPPLY_PROP_PRESENT && - chip->gpio_detect) { - ret = gpio_get_value(chip->pdata->battery_detect); - if (ret == chip->pdata->battery_detect_present) - val->intval = 1; - else - val->intval = 0; + if (psp == POWER_SUPPLY_PROP_PRESENT && chip->gpio_detect) { + ret = gpiod_get_value_cansleep(chip->gpio_detect); + if (ret < 0) + return ret; + val->intval = ret; chip->is_present = val->intval; return ret; } @@ -683,7 +681,12 @@ static irqreturn_t sbs_irq(int irq, void *devid) { struct sbs_info *chip = devid; struct power_supply *battery = chip->power_supply; + int ret; + ret = gpiod_get_value_cansleep(chip->gpio_detect); + if (ret < 0) + return ret; + chip->is_present = ret; power_supply_changed(battery); return IRQ_HANDLED; @@ -750,12 +753,11 @@ static const struct of_device_id sbs_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, sbs_dt_ids); -static struct sbs_platform_data *sbs_of_populate_pdata( - struct i2c_client *client) +static struct sbs_platform_data *sbs_of_populate_pdata(struct sbs_info *chip) { + struct i2c_client *client = chip->client; struct device_node *of_node = client->dev.of_node; - struct sbs_platform_data *pdata = client->dev.platform_data; - enum of_gpio_flags gpio_flags; + struct sbs_platform_data *pdata; int rc; u32 prop; @@ -763,22 +765,17 @@ static struct sbs_platform_data *sbs_of_populate_pdata( if (!of_node) return NULL; - /* if platform data is set, honor it */ - if (pdata) - return pdata; - /* first make sure at least one property is set, otherwise * it won't change behavior from running without pdata. */ if (!of_get_property(of_node, "sbs,i2c-retry-count", NULL) && - !of_get_property(of_node, "sbs,poll-retry-count", NULL) && - !of_get_property(of_node, "sbs,battery-detect-gpios", NULL)) + !of_get_property(of_node, "sbs,poll-retry-count", NULL)) goto of_out; pdata = devm_kzalloc(&client->dev, sizeof(struct sbs_platform_data), GFP_KERNEL); if (!pdata) - goto of_out; + return ERR_PTR(-ENOMEM); rc = of_property_read_u32(of_node, "sbs,i2c-retry-count", &prop); if (!rc) @@ -788,27 +785,14 @@ static struct sbs_platform_data *sbs_of_populate_pdata( if (!rc) pdata->poll_retry_count = prop; - if (!of_get_property(of_node, "sbs,battery-detect-gpios", NULL)) { - pdata->battery_detect = -1; - goto of_out; - } - - pdata->battery_detect = of_get_named_gpio_flags(of_node, - "sbs,battery-detect-gpios", 0, &gpio_flags); - - if (gpio_flags & OF_GPIO_ACTIVE_LOW) - pdata->battery_detect_present = 0; - else - pdata->battery_detect_present = 1; - of_out: return pdata; } #else static struct sbs_platform_data *sbs_of_populate_pdata( - struct i2c_client *client) + struct sbs_info *client) { - return client->dev.platform_data; + return ERR_PTR(-ENOSYS); } #endif @@ -846,7 +830,6 @@ static int sbs_probe(struct i2c_client *client, chip->client = client; chip->enable_detection = false; - chip->gpio_detect = false; psy_cfg.of_node = client->dev.of_node; psy_cfg.drv_data = chip; /* ignore first notification of external change, it is generated @@ -855,11 +838,20 @@ static int sbs_probe(struct i2c_client *client, chip->ignore_changes = 1; chip->last_state = POWER_SUPPLY_STATUS_UNKNOWN; - pdata = sbs_of_populate_pdata(client); + if (!pdata) + pdata = sbs_of_populate_pdata(chip); - if (pdata) { - chip->gpio_detect = gpio_is_valid(pdata->battery_detect); - chip->pdata = pdata; + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + + chip->pdata = pdata; + + chip->gpio_detect = devm_gpiod_get_optional(&client->dev, + "sbs,battery-detect", GPIOD_IN); + if (IS_ERR(chip->gpio_detect)) { + dev_err(&client->dev, "Failed to get gpio: %ld\n", + PTR_ERR(chip->gpio_detect)); + return PTR_ERR(chip->gpio_detect); } i2c_set_clientdata(client, chip); @@ -867,26 +859,9 @@ static int sbs_probe(struct i2c_client *client, if (!chip->gpio_detect) goto skip_gpio; - rc = gpio_request(pdata->battery_detect, dev_name(&client->dev)); - if (rc) { - dev_warn(&client->dev, "Failed to request gpio: %d\n", rc); - chip->gpio_detect = false; - goto skip_gpio; - } - - rc = gpio_direction_input(pdata->battery_detect); - if (rc) { - dev_warn(&client->dev, "Failed to get gpio as input: %d\n", rc); - gpio_free(pdata->battery_detect); - chip->gpio_detect = false; - goto skip_gpio; - } - - irq = gpio_to_irq(pdata->battery_detect); + irq = gpiod_to_irq(chip->gpio_detect); if (irq <= 0) { dev_warn(&client->dev, "Failed to get gpio as irq: %d\n", irq); - gpio_free(pdata->battery_detect); - chip->gpio_detect = false; goto skip_gpio; } @@ -895,8 +870,6 @@ static int sbs_probe(struct i2c_client *client, dev_name(&client->dev), chip); if (rc) { dev_warn(&client->dev, "Failed to request irq: %d\n", rc); - gpio_free(pdata->battery_detect); - chip->gpio_detect = false; goto skip_gpio; } @@ -905,7 +878,7 @@ skip_gpio: * Before we register, we might need to make sure we can actually talk * to the battery. */ - if (!force_load) { + if (!(force_load || chip->gpio_detect)) { rc = sbs_read_word_data(client, sbs_data[REG_STATUS].addr); if (rc < 0) { @@ -934,9 +907,6 @@ skip_gpio: return 0; exit_psupply: - if (chip->gpio_detect) - gpio_free(pdata->battery_detect); - return rc; } @@ -944,9 +914,6 @@ static int sbs_remove(struct i2c_client *client) { struct sbs_info *chip = i2c_get_clientdata(client); - if (chip->gpio_detect) - gpio_free(chip->pdata->battery_detect); - cancel_delayed_work_sync(&chip->work); return 0; diff --git a/include/linux/power/sbs-battery.h b/include/linux/power/sbs-battery.h index 2b0a9d9ff57e..811f1a0c00cb 100644 --- a/include/linux/power/sbs-battery.h +++ b/include/linux/power/sbs-battery.h @@ -26,15 +26,11 @@ /** * struct sbs_platform_data - platform data for sbs devices - * @battery_detect: GPIO which is used to detect battery presence - * @battery_detect_present: gpio state when battery is present (0 / 1) * @i2c_retry_count: # of times to retry on i2c IO failure * @poll_retry_count: # of times to retry looking for new status after * external change notification */ struct sbs_platform_data { - int battery_detect; - int battery_detect_present; int i2c_retry_count; int poll_retry_count; }; From c65a8b51123a14f6960e4238bfa4673d54ee183a Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Sat, 3 Sep 2016 00:09:53 +0200 Subject: [PATCH 35/46] power: supply: bq24735-charger: Request status GPIO with initial input setup This requests the status GPIO with initial input setup. It is required to read the GPIO status at probe time and thus correctly avoid sending I2C messages when AC is not plugged. When requesting the GPIO without initial input setup, it always reads 0 which causes probe to fail as it assumes the charger is connected, sends I2C messages and fails. While at it, this switches the driver over to gpiod API. Signed-off-by: Paul Kocialkowski Signed-off-by: Sebastian Reichel --- drivers/power/supply/bq24735-charger.c | 39 ++++++++------------------ include/linux/power/bq24735-charger.h | 4 --- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/drivers/power/supply/bq24735-charger.c b/drivers/power/supply/bq24735-charger.c index dc460bb03d84..eb7783b42e0a 100644 --- a/drivers/power/supply/bq24735-charger.c +++ b/drivers/power/supply/bq24735-charger.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include @@ -49,6 +49,7 @@ struct bq24735 { struct i2c_client *client; struct bq24735_platform *pdata; struct mutex lock; + struct gpio_desc *status_gpio; bool charging; }; @@ -177,12 +178,8 @@ static int bq24735_config_charger(struct bq24735 *charger) static bool bq24735_charger_is_present(struct bq24735 *charger) { - struct bq24735_platform *pdata = charger->pdata; - int ret; - - if (pdata->status_gpio_valid) { - ret = gpio_get_value_cansleep(pdata->status_gpio); - return ret ^= pdata->status_gpio_active_low == 0; + if (charger->status_gpio) { + return !gpiod_get_value_cansleep(charger->status_gpio); } else { int ac = 0; @@ -308,7 +305,6 @@ static struct bq24735_platform *bq24735_parse_dt_data(struct i2c_client *client) struct device_node *np = client->dev.of_node; u32 val; int ret; - enum of_gpio_flags flags; pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) { @@ -317,12 +313,6 @@ static struct bq24735_platform *bq24735_parse_dt_data(struct i2c_client *client) return NULL; } - pdata->status_gpio = of_get_named_gpio_flags(np, "ti,ac-detect-gpios", - 0, &flags); - - if (flags & OF_GPIO_ACTIVE_LOW) - pdata->status_gpio_active_low = 1; - ret = of_property_read_u32(np, "ti,charge-current", &val); if (!ret) pdata->charge_current = val; @@ -396,21 +386,16 @@ static int bq24735_charger_probe(struct i2c_client *client, i2c_set_clientdata(client, charger); - if (gpio_is_valid(charger->pdata->status_gpio)) { - ret = devm_gpio_request(&client->dev, - charger->pdata->status_gpio, - name); - if (ret) { - dev_err(&client->dev, - "Failed GPIO request for GPIO %d: %d\n", - charger->pdata->status_gpio, ret); - } - - charger->pdata->status_gpio_valid = !ret; + charger->status_gpio = devm_gpiod_get_optional(&client->dev, + "ti,ac-detect", + GPIOD_IN); + if (IS_ERR(charger->status_gpio)) { + ret = PTR_ERR(charger->status_gpio); + dev_err(&client->dev, "Getting gpio failed: %d\n", ret); + return ret; } - if (!charger->pdata->status_gpio_valid - || bq24735_charger_is_present(charger)) { + if (!charger->status_gpio || bq24735_charger_is_present(charger)) { ret = bq24735_read_word(client, BQ24735_MANUFACTURER_ID); if (ret < 0) { dev_err(&client->dev, "Failed to read manufacturer id : %d\n", diff --git a/include/linux/power/bq24735-charger.h b/include/linux/power/bq24735-charger.h index 6b750c1a45fa..b04be59f914c 100644 --- a/include/linux/power/bq24735-charger.h +++ b/include/linux/power/bq24735-charger.h @@ -28,10 +28,6 @@ struct bq24735_platform { const char *name; - int status_gpio; - int status_gpio_active_low; - bool status_gpio_valid; - bool ext_control; char **supplied_to; From 9edeaada19a21eb669ae0dfe749be88f1810ea92 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 6 Sep 2016 15:16:33 +0200 Subject: [PATCH 36/46] power: supply: sbs-battery: simplify DT parsing After the change to use the gpio descriptor interface, we get a warning if -Wmaybe-uninitialized is added back to the build flags (it is currently disabled: drivers/power/supply/sbs-battery.c: In function 'sbs_probe': drivers/power/supply/sbs-battery.c:760:28: error: 'pdata' may be used uninitialized in this function [-Werror=maybe-uninitialized] The problem is that if neither the DT properties nor a platform_data pointer are provided, the chip->pdata pointer gets set to an uninitialized value. Looking at the code some more, I found that the sbs_of_populate_pdata function is more complex than necessary and has confusing calling conventions of possibly returning a valid pointer, a NULL pointer or an ERR_PTR pointer (in addition to the uninitialized pointer). To fix all of that, this gets rid of the chip->pdata pointer and simply moves the two integers into the sbs_info structure. This makes it much clearer from reading sbs_probe() what the precedence of the three possible values are (pdata, DT, hardcoded defaults) and completely avoids the #ifdef CONFIG_OF guards as of_property_read_u32() gets replaced with a compile-time stub when that is disabled, and returns an error if passed a NULL of_node pointer. Signed-off-by: Arnd Bergmann Fixes: 3b5dd3a49496 ("power: supply: sbs-battery: Use gpio_desc and sleeping calls for battery detect") Signed-off-by: Sebastian Reichel --- drivers/power/supply/sbs-battery.c | 94 +++++++++--------------------- 1 file changed, 29 insertions(+), 65 deletions(-) diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index 8b4c6a8681b0..248a5dd75e22 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -169,6 +169,8 @@ struct sbs_info { bool enable_detection; int last_state; int poll_time; + int i2c_retry_count; + int poll_retry_count; struct delayed_work work; int ignore_changes; }; @@ -184,7 +186,7 @@ static int sbs_read_word_data(struct i2c_client *client, u8 address) int retries = 1; if (chip->pdata) - retries = max(chip->pdata->i2c_retry_count + 1, 1); + retries = max(chip->i2c_retry_count + 1, 1); while (retries > 0) { ret = i2c_smbus_read_word_data(client, address); @@ -212,8 +214,8 @@ static int sbs_read_string_data(struct i2c_client *client, u8 address, u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; if (chip->pdata) { - retries_length = max(chip->pdata->i2c_retry_count + 1, 1); - retries_block = max(chip->pdata->i2c_retry_count + 1, 1); + retries_length = max(chip->i2c_retry_count + 1, 1); + retries_block = max(chip->i2c_retry_count + 1, 1); } /* Adapter needs to support these two functions */ @@ -279,7 +281,7 @@ static int sbs_write_word_data(struct i2c_client *client, u8 address, int retries = 1; if (chip->pdata) - retries = max(chip->pdata->i2c_retry_count + 1, 1); + retries = max(chip->i2c_retry_count + 1, 1); while (retries > 0) { ret = i2c_smbus_write_word_data(client, address, @@ -741,61 +743,6 @@ static void sbs_delayed_work(struct work_struct *work) } } -#if defined(CONFIG_OF) - -#include -#include - -static const struct of_device_id sbs_dt_ids[] = { - { .compatible = "sbs,sbs-battery" }, - { .compatible = "ti,bq20z75" }, - { } -}; -MODULE_DEVICE_TABLE(of, sbs_dt_ids); - -static struct sbs_platform_data *sbs_of_populate_pdata(struct sbs_info *chip) -{ - struct i2c_client *client = chip->client; - struct device_node *of_node = client->dev.of_node; - struct sbs_platform_data *pdata; - int rc; - u32 prop; - - /* verify this driver matches this device */ - if (!of_node) - return NULL; - - /* first make sure at least one property is set, otherwise - * it won't change behavior from running without pdata. - */ - if (!of_get_property(of_node, "sbs,i2c-retry-count", NULL) && - !of_get_property(of_node, "sbs,poll-retry-count", NULL)) - goto of_out; - - pdata = devm_kzalloc(&client->dev, sizeof(struct sbs_platform_data), - GFP_KERNEL); - if (!pdata) - return ERR_PTR(-ENOMEM); - - rc = of_property_read_u32(of_node, "sbs,i2c-retry-count", &prop); - if (!rc) - pdata->i2c_retry_count = prop; - - rc = of_property_read_u32(of_node, "sbs,poll-retry-count", &prop); - if (!rc) - pdata->poll_retry_count = prop; - -of_out: - return pdata; -} -#else -static struct sbs_platform_data *sbs_of_populate_pdata( - struct sbs_info *client) -{ - return ERR_PTR(-ENOSYS); -} -#endif - static const struct power_supply_desc sbs_default_desc = { .type = POWER_SUPPLY_TYPE_BATTERY, .properties = sbs_properties, @@ -838,13 +785,23 @@ static int sbs_probe(struct i2c_client *client, chip->ignore_changes = 1; chip->last_state = POWER_SUPPLY_STATUS_UNKNOWN; - if (!pdata) - pdata = sbs_of_populate_pdata(chip); + /* use pdata if available, fall back to DT properties, + * or hardcoded defaults if not + */ + rc = of_property_read_u32(client->dev.of_node, "sbs,i2c-retry-count", + &chip->i2c_retry_count); + if (rc) + chip->i2c_retry_count = 1; - if (IS_ERR(pdata)) - return PTR_ERR(pdata); + rc = of_property_read_u32(client->dev.of_node, "sbs,poll-retry-count", + &chip->poll_retry_count); + if (rc) + chip->poll_retry_count = 0; - chip->pdata = pdata; + if (pdata) { + chip->poll_retry_count = pdata->poll_retry_count; + chip->i2c_retry_count = pdata->i2c_retry_count; + } chip->gpio_detect = devm_gpiod_get_optional(&client->dev, "sbs,battery-detect", GPIOD_IN); @@ -953,13 +910,20 @@ static const struct i2c_device_id sbs_id[] = { }; MODULE_DEVICE_TABLE(i2c, sbs_id); +static const struct of_device_id sbs_dt_ids[] = { + { .compatible = "sbs,sbs-battery" }, + { .compatible = "ti,bq20z75" }, + { } +}; +MODULE_DEVICE_TABLE(of, sbs_dt_ids); + static struct i2c_driver sbs_battery_driver = { .probe = sbs_probe, .remove = sbs_remove, .id_table = sbs_id, .driver = { .name = "sbs-battery", - .of_match_table = of_match_ptr(sbs_dt_ids), + .of_match_table = sbs_dt_ids, .pm = SBS_PM_OPS, }, }; From 0610735928ee47870e083d5901caa371089216f1 Mon Sep 17 00:00:00 2001 From: Georges Savoundararadj Date: Wed, 7 Sep 2016 18:38:15 -0700 Subject: [PATCH 37/46] power: bq24257: Fix use of uninitialized pointer bq->charger bq->charger is initialized in bq24257_power_supply_init. Therefore, bq24257_power_supply_init should be called before the registration of the IRQ handler bq24257_irq_handler_thread that calls power_supply_changed(bq->charger). Signed-off-by: Georges Savoundararadj Cc: Aurelien Chanot Cc: Andreas Dannenberg Cc: Sebastian Reichel Cc: David Woodhouse Fixes: 2219a935963e ("power_supply: Add TI BQ24257 charger driver") Signed-off-by: Sebastian Reichel --- drivers/power/supply/bq24257_charger.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/power/supply/bq24257_charger.c b/drivers/power/supply/bq24257_charger.c index 1fea2c7ef97f..6fc31bdc639b 100644 --- a/drivers/power/supply/bq24257_charger.c +++ b/drivers/power/supply/bq24257_charger.c @@ -1068,6 +1068,12 @@ static int bq24257_probe(struct i2c_client *client, return ret; } + ret = bq24257_power_supply_init(bq); + if (ret < 0) { + dev_err(dev, "Failed to register power supply\n"); + return ret; + } + ret = devm_request_threaded_irq(dev, client->irq, NULL, bq24257_irq_handler_thread, IRQF_TRIGGER_FALLING | @@ -1078,12 +1084,6 @@ static int bq24257_probe(struct i2c_client *client, return ret; } - ret = bq24257_power_supply_init(bq); - if (ret < 0) { - dev_err(dev, "Failed to register power supply\n"); - return ret; - } - ret = sysfs_create_group(&bq->charger->dev.kobj, &bq24257_attr_group); if (ret < 0) { dev_err(dev, "Can't create sysfs entries\n"); From 17c6d3979e5bbff1de36a4e89015fa09ac495d27 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 8 Sep 2016 19:10:00 -0700 Subject: [PATCH 38/46] sbs-battery: make writes to ManufacturerAccess optional According to the Smart Battery Data Specification, the use of ManufacturerAcess (register 0x0) is implementation-defined. It appears that some batteries use writes to this register in order to implement certain functionality, but others may simply NAK all writes to it. As a result, write failures to ManufacturerAccess should not be used as an indicator of battery presence, nor as a failure to enter sleep mode. The failed write access was seen with SANYO AP13J3K. Cc: Brian Norris Signed-off-by: Guenter Roeck Signed-off-by: Sebastian Reichel --- drivers/power/supply/sbs-battery.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index 248a5dd75e22..bc7acdf84d60 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -317,21 +317,22 @@ static int sbs_get_battery_presence_and_health( return ret; } - /* Write to ManufacturerAccess with - * ManufacturerAccess command and then - * read the status */ - ret = sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr, - MANUFACTURER_ACCESS_STATUS); + /* + * Write to ManufacturerAccess with ManufacturerAccess command + * and then read the status. Do not check for error on the write + * since not all batteries implement write access to this command, + * while others mandate it. + */ + sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr, + MANUFACTURER_ACCESS_STATUS); + + ret = sbs_read_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr); if (ret < 0) { if (psp == POWER_SUPPLY_PROP_PRESENT) val->intval = 0; /* battery removed */ return ret; } - ret = sbs_read_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr); - if (ret < 0) - return ret; - if (ret < sbs_data[REG_MANUFACTURER_DATA].min_value || ret > sbs_data[REG_MANUFACTURER_DATA].max_value) { val->intval = 0; @@ -882,16 +883,16 @@ static int sbs_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct sbs_info *chip = i2c_get_clientdata(client); - s32 ret; if (chip->poll_time > 0) cancel_delayed_work_sync(&chip->work); - /* write to manufacturer access with sleep command */ - ret = sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr, + /* + * Write to manufacturer access with sleep command. + * Support is manufacturer dependend, so ignore errors. + */ + sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr, MANUFACTURER_ACCESS_SLEEP); - if (chip->is_present && ret < 0) - return ret; return 0; } From 1dff6ce0262bc42beb801527bd4725c6b8af0683 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 12 Sep 2016 14:05:04 +0100 Subject: [PATCH 39/46] power: reset: add in missing white space in error message text A dev_err message spans two lines and the literal string is missing a white space between words. Add the white space. Signed-off-by: Colin Ian King Signed-off-by: Sebastian Reichel --- drivers/power/reset/keystone-reset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/reset/keystone-reset.c b/drivers/power/reset/keystone-reset.c index c70f1bffe038..09380857a1c5 100644 --- a/drivers/power/reset/keystone-reset.c +++ b/drivers/power/reset/keystone-reset.c @@ -139,7 +139,7 @@ static int rsctrl_probe(struct platform_device *pdev) } if (val >= WDT_MUX_NUMBER) { - dev_err(dev, "ti,wdt-list property can contain" + dev_err(dev, "ti,wdt-list property can contain " "only numbers < 4\n"); return -EINVAL; } From f04f7aef7f6aafdc0ba54c6b9670cd11f9d9200a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 13 Sep 2016 03:23:21 +0900 Subject: [PATCH 40/46] power: supply: ab8500: cleanup with list_first_entry_or_null() The combo of list_empty() check and return list_first_entry() can be replaced with list_first_entry_or_null(). Signed-off-by: Masahiro Yamada Signed-off-by: Sebastian Reichel --- drivers/power/supply/ab8500_fg.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 199f2dbb0044..2199f673118c 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -245,13 +245,8 @@ static LIST_HEAD(ab8500_fg_list); */ struct ab8500_fg *ab8500_fg_get(void) { - struct ab8500_fg *fg; - - if (list_empty(&ab8500_fg_list)) - return NULL; - - fg = list_first_entry(&ab8500_fg_list, struct ab8500_fg, node); - return fg; + return list_first_entry_or_null(&ab8500_fg_list, struct ab8500_fg, + node); } /* Main battery properties */ From 896af83ef69b0a325816fe270440baa27238f531 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Wed, 14 Sep 2016 16:25:39 +0530 Subject: [PATCH 41/46] power: reset: xgene-reboot: Unmap region obtained by of_iomap Free memory mapping, if probe is not successful. Signed-off-by: Arvind Yadav Signed-off-by: Sebastian Reichel --- drivers/power/reset/xgene-reboot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/power/reset/xgene-reboot.c b/drivers/power/reset/xgene-reboot.c index f07e93c97ba3..73c3d93e5318 100644 --- a/drivers/power/reset/xgene-reboot.c +++ b/drivers/power/reset/xgene-reboot.c @@ -81,8 +81,10 @@ static int xgene_reboot_probe(struct platform_device *pdev) ctx->restart_handler.notifier_call = xgene_restart_handler; ctx->restart_handler.priority = 128; err = register_restart_handler(&ctx->restart_handler); - if (err) + if (err) { + iounmap(ctx->csr); dev_err(dev, "cannot register restart handler (err=%d)\n", err); + } return err; } From 7531be5cdfb1e81d25c299be0bcf8e615474e227 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Wed, 14 Sep 2016 16:35:31 +0530 Subject: [PATCH 42/46] power: reset: zx-reboot: Unmap region obtained by of_iomap Free memory mapping, if probe is not successful. Signed-off-by: Arvind Yadav Signed-off-by: Sebastian Reichel --- drivers/power/reset/zx-reboot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/power/reset/zx-reboot.c b/drivers/power/reset/zx-reboot.c index a5b009673d0e..b0b1eb3a78c2 100644 --- a/drivers/power/reset/zx-reboot.c +++ b/drivers/power/reset/zx-reboot.c @@ -58,9 +58,12 @@ static int zx_reboot_probe(struct platform_device *pdev) } err = register_restart_handler(&zx_restart_nb); - if (err) + if (err) { + iounmap(base); + iounmap(pcu_base); dev_err(&pdev->dev, "Register restart handler failed(err=%d)\n", err); + } return err; } From 8ad5d85efd813281046cb87366c350321a2d64ca Mon Sep 17 00:00:00 2001 From: Peter Griffin Date: Wed, 14 Sep 2016 14:27:54 +0100 Subject: [PATCH 43/46] power: reset: st-poweroff: Remove obsolete platforms. This patch removes support for STiH415/6 SoC's from the st-poweroff driver, as support for these platforms is being removed from the kernel. Signed-off-by: Peter Griffin Cc: Signed-off-by: Sebastian Reichel --- drivers/power/reset/st-poweroff.c | 41 ------------------------------- 1 file changed, 41 deletions(-) diff --git a/drivers/power/reset/st-poweroff.c b/drivers/power/reset/st-poweroff.c index a488877a3538..2046b31232f7 100644 --- a/drivers/power/reset/st-poweroff.c +++ b/drivers/power/reset/st-poweroff.c @@ -28,28 +28,6 @@ struct reset_syscfg { unsigned int mask_rst_msk; }; -/* STiH415 */ -#define STIH415_SYSCFG_11 0x2c -#define STIH415_SYSCFG_15 0x3c - -static struct reset_syscfg stih415_reset = { - .offset_rst = STIH415_SYSCFG_11, - .mask_rst = BIT(0), - .offset_rst_msk = STIH415_SYSCFG_15, - .mask_rst_msk = BIT(0) -}; - -/* STiH416 */ -#define STIH416_SYSCFG_500 0x7d0 -#define STIH416_SYSCFG_504 0x7e0 - -static struct reset_syscfg stih416_reset = { - .offset_rst = STIH416_SYSCFG_500, - .mask_rst = BIT(0), - .offset_rst_msk = STIH416_SYSCFG_504, - .mask_rst_msk = BIT(0) -}; - /* STiH407 */ #define STIH407_SYSCFG_4000 0x0 #define STIH407_SYSCFG_4008 0x20 @@ -61,16 +39,6 @@ static struct reset_syscfg stih407_reset = { .mask_rst_msk = BIT(0) }; -/* STiD127 */ -#define STID127_SYSCFG_700 0x0 -#define STID127_SYSCFG_773 0x124 - -static struct reset_syscfg stid127_reset = { - .offset_rst = STID127_SYSCFG_773, - .mask_rst = BIT(0), - .offset_rst_msk = STID127_SYSCFG_700, - .mask_rst_msk = BIT(8) -}; static struct reset_syscfg *st_restart_syscfg; @@ -99,17 +67,8 @@ static struct notifier_block st_restart_nb = { static const struct of_device_id st_reset_of_match[] = { { - .compatible = "st,stih415-restart", - .data = (void *)&stih415_reset, - }, { - .compatible = "st,stih416-restart", - .data = (void *)&stih416_reset, - }, { .compatible = "st,stih407-restart", .data = (void *)&stih407_reset, - }, { - .compatible = "st,stid127-restart", - .data = (void *)&stid127_reset, }, {} }; From bb1e41ba324fe4bb71be3ef8d0eda29f0ba44ffa Mon Sep 17 00:00:00 2001 From: Peter Griffin Date: Wed, 14 Sep 2016 14:27:55 +0100 Subject: [PATCH 44/46] power: reset: st: Remove obsolete platforms from dt doc This patch removes support for STiH415/6 SoC's from the st-restart dt binding documentation, as support for these platforms is being removed from the kernel. It also updates the dt example to a currently supported platform. Signed-off-by: Peter Griffin Cc: Signed-off-by: Sebastian Reichel --- Documentation/devicetree/bindings/power/reset/st-reset.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/power/reset/st-reset.txt b/Documentation/devicetree/bindings/power/reset/st-reset.txt index 809af54f02f3..83734dc3a389 100644 --- a/Documentation/devicetree/bindings/power/reset/st-reset.txt +++ b/Documentation/devicetree/bindings/power/reset/st-reset.txt @@ -1,11 +1,12 @@ *Device-Tree bindings for ST SW reset functionality Required properties: -- compatible: should be "st,-restart". +- compatible: should be "stih407-restart". - st,syscfg: should be a phandle of the syscfg node. Example node: restart { - compatible = "st,stih416-restart"; - st,syscfg = <&syscfg_sbc>; + compatible = "st,stih407-restart"; + st,syscfg = <&syscfg_sbc_reg>; + status = "okay"; }; From 389958bb6be8b08c9f6d350dcaa9fc127123eada Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Tue, 20 Sep 2016 09:01:12 +0800 Subject: [PATCH 45/46] power: supply: sbs-battery: Cleanup removal of chip->pdata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There where still a few lingering references to pdata after commit power: supply: sbs-battery: simplify DT parsing. Remove pdata from struct·sbs_info and conditional checks to ser if this was set from the i2c read / write functions. Instead of call max in each function for incrementing poll_retry_count do it once in the probe function. Fixup null pointer dereference in to pdata in sbs_external_power_changed. Change retry counts to u32 to avoid need for max. Signed-off-by: Phil Reid Signed-off-by: Sebastian Reichel --- drivers/power/supply/sbs-battery.c | 22 +++++++++------------- include/linux/power/sbs-battery.h | 4 ++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index bc7acdf84d60..8bb2eb38eb1c 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -163,14 +163,13 @@ static enum power_supply_property sbs_properties[] = { struct sbs_info { struct i2c_client *client; struct power_supply *power_supply; - struct sbs_platform_data *pdata; bool is_present; struct gpio_desc *gpio_detect; bool enable_detection; int last_state; int poll_time; - int i2c_retry_count; - int poll_retry_count; + u32 i2c_retry_count; + u32 poll_retry_count; struct delayed_work work; int ignore_changes; }; @@ -185,8 +184,7 @@ static int sbs_read_word_data(struct i2c_client *client, u8 address) s32 ret = 0; int retries = 1; - if (chip->pdata) - retries = max(chip->i2c_retry_count + 1, 1); + retries = chip->i2c_retry_count; while (retries > 0) { ret = i2c_smbus_read_word_data(client, address); @@ -213,10 +211,8 @@ static int sbs_read_string_data(struct i2c_client *client, u8 address, int retries_length = 1, retries_block = 1; u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; - if (chip->pdata) { - retries_length = max(chip->i2c_retry_count + 1, 1); - retries_block = max(chip->i2c_retry_count + 1, 1); - } + retries_length = chip->i2c_retry_count; + retries_block = chip->i2c_retry_count; /* Adapter needs to support these two functions */ if (!i2c_check_functionality(client->adapter, @@ -280,8 +276,7 @@ static int sbs_write_word_data(struct i2c_client *client, u8 address, s32 ret = 0; int retries = 1; - if (chip->pdata) - retries = max(chip->i2c_retry_count + 1, 1); + retries = chip->i2c_retry_count; while (retries > 0) { ret = i2c_smbus_write_word_data(client, address, @@ -708,7 +703,7 @@ static void sbs_external_power_changed(struct power_supply *psy) cancel_delayed_work_sync(&chip->work); schedule_delayed_work(&chip->work, HZ); - chip->poll_time = chip->pdata->poll_retry_count; + chip->poll_time = chip->poll_retry_count; } static void sbs_delayed_work(struct work_struct *work) @@ -792,7 +787,7 @@ static int sbs_probe(struct i2c_client *client, rc = of_property_read_u32(client->dev.of_node, "sbs,i2c-retry-count", &chip->i2c_retry_count); if (rc) - chip->i2c_retry_count = 1; + chip->i2c_retry_count = 0; rc = of_property_read_u32(client->dev.of_node, "sbs,poll-retry-count", &chip->poll_retry_count); @@ -803,6 +798,7 @@ static int sbs_probe(struct i2c_client *client, chip->poll_retry_count = pdata->poll_retry_count; chip->i2c_retry_count = pdata->i2c_retry_count; } + chip->i2c_retry_count = chip->i2c_retry_count + 1; chip->gpio_detect = devm_gpiod_get_optional(&client->dev, "sbs,battery-detect", GPIOD_IN); diff --git a/include/linux/power/sbs-battery.h b/include/linux/power/sbs-battery.h index 811f1a0c00cb..519b8b43239a 100644 --- a/include/linux/power/sbs-battery.h +++ b/include/linux/power/sbs-battery.h @@ -31,8 +31,8 @@ * external change notification */ struct sbs_platform_data { - int i2c_retry_count; - int poll_retry_count; + u32 i2c_retry_count; + u32 poll_retry_count; }; #endif From 1d72706f0485b58e151b5a7584c4c65d66670587 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Mon, 19 Sep 2016 20:43:02 -0700 Subject: [PATCH 46/46] power: supply: bq27xxx_battery: allow kernel poll_interval parameter runtime update Fix issue with poll_interval being not updated till the previous interval expired. Cc: Tony Lindgren Cc: Liam Breck Signed-off-by: Matt Ranostay Signed-off-by: Sebastian Reichel --- drivers/power/supply/bq27xxx_battery.c | 38 +++++++++++++++++++++++++- include/linux/power/bq27xxx_battery.h | 1 + 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c index 3f57dd54803a..3b0dbc689d72 100644 --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -390,8 +391,35 @@ static struct { BQ27XXX_PROP(BQ27421, bq27421_battery_props), }; +static DEFINE_MUTEX(bq27xxx_list_lock); +static LIST_HEAD(bq27xxx_battery_devices); + +static int poll_interval_param_set(const char *val, const struct kernel_param *kp) +{ + struct bq27xxx_device_info *di; + int ret; + + ret = param_set_uint(val, kp); + if (ret < 0) + return ret; + + mutex_lock(&bq27xxx_list_lock); + list_for_each_entry(di, &bq27xxx_battery_devices, list) { + cancel_delayed_work_sync(&di->work); + schedule_delayed_work(&di->work, 0); + } + mutex_unlock(&bq27xxx_list_lock); + + return ret; +} + +static const struct kernel_param_ops param_ops_poll_interval = { + .get = param_get_uint, + .set = poll_interval_param_set, +}; + static unsigned int poll_interval = 360; -module_param(poll_interval, uint, 0644); +module_param_cb(poll_interval, ¶m_ops_poll_interval, &poll_interval, 0644); MODULE_PARM_DESC(poll_interval, "battery poll interval in seconds - 0 disables polling"); @@ -972,6 +1000,10 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di) bq27xxx_battery_update(di); + mutex_lock(&bq27xxx_list_lock); + list_add(&di->list, &bq27xxx_battery_devices); + mutex_unlock(&bq27xxx_list_lock); + return 0; } EXPORT_SYMBOL_GPL(bq27xxx_battery_setup); @@ -990,6 +1022,10 @@ void bq27xxx_battery_teardown(struct bq27xxx_device_info *di) power_supply_unregister(di->bat); + mutex_lock(&bq27xxx_list_lock); + list_del(&di->list); + mutex_unlock(&bq27xxx_list_lock); + mutex_destroy(&di->lock); } EXPORT_SYMBOL_GPL(bq27xxx_battery_teardown); diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h index b50c0492629d..e30deb046156 100644 --- a/include/linux/power/bq27xxx_battery.h +++ b/include/linux/power/bq27xxx_battery.h @@ -58,6 +58,7 @@ struct bq27xxx_device_info { unsigned long last_update; struct delayed_work work; struct power_supply *bat; + struct list_head list; struct mutex lock; u8 *regs; };