Skip to content

Commit

Permalink
Merge tag 'for-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:

 - new driver for Intel PIIX4

 - lots of module autoload fixes

 - misc fixes

* tag 'for-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  power_supply: wm97xx_battery: use power_supply_get_drvdata
  wm8350_power: use permission-specific DEVICE_ATTR variants
  power: ipaq_micro_battery: fix alias
  power: supply: bq27xxx_battery: Fix register map for BQ27510 and BQ27520
  bq24190_charger: Fix PM runtime use for bq24190_battery_set_property
  power: supply: lp8788: remove an unneeded NULL check
  power: reset: zx-reboot: Fix module autoload
  power: reset: syscon-reboot-mode: Fix module autoload
  power: reset: at91-poweroff: Fix module autoload
  power: reset: at91-reset: Fix module autoload
  power: supply: axp288_fuel_gauge: Fix module autoload
  power: supply: max8997_charger: Fix module autoload
  power: supply: max17040: Change register transaction length from 8 bits to 16 bits
  power: supply: bq27xxx_battery: don't update poll_interval param if same
  power: supply: improve function-level documentation
  power: reset: Add Intel PIIX4 poweroff driver
  • Loading branch information
Linus Torvalds committed Dec 14, 2016
2 parents ce38207 + 6480af4 commit bbcd9c5
Show file tree
Hide file tree
Showing 21 changed files with 217 additions and 65 deletions.
2 changes: 1 addition & 1 deletion drivers/input/touchscreen/wm97xx-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ static int wm97xx_probe(struct device *dev)
}
platform_set_drvdata(wm->battery_dev, wm);
wm->battery_dev->dev.parent = dev;
wm->battery_dev->dev.platform_data = pdata;
wm->battery_dev->dev.platform_data = pdata->batt_pdata;
ret = platform_device_add(wm->battery_dev);
if (ret < 0)
goto batt_reg_err;
Expand Down
10 changes: 10 additions & 0 deletions drivers/power/reset/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ config POWER_RESET_MSM
help
Power off and restart support for Qualcomm boards.

config POWER_RESET_PIIX4_POWEROFF
tristate "Intel PIIX4 power-off driver"
depends on PCI
depends on MIPS || COMPILE_TEST
help
This driver supports powering off a system using the Intel PIIX4
southbridge, for example the MIPS Malta development board. The
southbridge SOff state is entered in response to a request to
power off the system.

config POWER_RESET_LTC2952
bool "LTC2952 PowerPath power-off driver"
depends on OF_GPIO
Expand Down
1 change: 1 addition & 0 deletions drivers/power/reset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o
obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o
obj-$(CONFIG_POWER_RESET_IMX) += imx-snvs-poweroff.o
obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
obj-$(CONFIG_POWER_RESET_PIIX4_POWEROFF) += piix4-poweroff.o
obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o
obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
Expand Down
1 change: 1 addition & 0 deletions drivers/power/reset/at91-poweroff.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ static const struct of_device_id at91_poweroff_of_match[] = {
{ .compatible = "atmel,at91sam9x5-shdwc", },
{ /*sentinel*/ }
};
MODULE_DEVICE_TABLE(of, at91_poweroff_of_match);

static struct platform_driver at91_poweroff_driver = {
.remove = __exit_p(at91_poweroff_remove),
Expand Down
2 changes: 2 additions & 0 deletions drivers/power/reset/at91-reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ static const struct of_device_id at91_reset_of_match[] = {
{ .compatible = "atmel,sama5d3-rstc", .data = sama5d3_restart },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, at91_reset_of_match);

static struct notifier_block at91_restart_nb = {
.priority = 192,
Expand Down Expand Up @@ -242,6 +243,7 @@ static const struct platform_device_id at91_reset_plat_match[] = {
{ "at91-sam9g45-reset", (unsigned long)at91sam9g45_restart },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(platform, at91_reset_plat_match);

static struct platform_driver at91_reset_driver = {
.remove = __exit_p(at91_reset_remove),
Expand Down
113 changes: 113 additions & 0 deletions drivers/power/reset/piix4-poweroff.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright (C) 2016 Imagination Technologies
* Author: Paul Burton <paul.burton@imgtec.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/

#include <linux/delay.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/pm.h>

static struct pci_dev *pm_dev;
static resource_size_t io_offset;

enum piix4_pm_io_reg {
PIIX4_FUNC3IO_PMSTS = 0x00,
#define PIIX4_FUNC3IO_PMSTS_PWRBTN_STS BIT(8)
PIIX4_FUNC3IO_PMCNTRL = 0x04,
#define PIIX4_FUNC3IO_PMCNTRL_SUS_EN BIT(13)
#define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF (0x0 << 10)
};

#define PIIX4_SUSPEND_MAGIC 0x00120002

static const int piix4_pm_io_region = PCI_BRIDGE_RESOURCES;

static void piix4_poweroff(void)
{
int spec_devid;
u16 sts;

/* Ensure the power button status is clear */
while (1) {
sts = inw(io_offset + PIIX4_FUNC3IO_PMSTS);
if (!(sts & PIIX4_FUNC3IO_PMSTS_PWRBTN_STS))
break;
outw(sts, io_offset + PIIX4_FUNC3IO_PMSTS);
}

/* Enable entry to suspend */
outw(PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF | PIIX4_FUNC3IO_PMCNTRL_SUS_EN,
io_offset + PIIX4_FUNC3IO_PMCNTRL);

/* If the special cycle occurs too soon this doesn't work... */
mdelay(10);

/*
* The PIIX4 will enter the suspend state only after seeing a special
* cycle with the correct magic data on the PCI bus. Generate that
* cycle now.
*/
spec_devid = PCI_DEVID(0, PCI_DEVFN(0x1f, 0x7));
pci_bus_write_config_dword(pm_dev->bus, spec_devid, 0,
PIIX4_SUSPEND_MAGIC);

/* Give the system some time to power down, then error */
mdelay(1000);
pr_emerg("Unable to poweroff system\n");
}

static int piix4_poweroff_probe(struct pci_dev *dev,
const struct pci_device_id *id)
{
int res;

if (pm_dev)
return -EINVAL;

/* Request access to the PIIX4 PM IO registers */
res = pci_request_region(dev, piix4_pm_io_region,
"PIIX4 PM IO registers");
if (res) {
dev_err(&dev->dev, "failed to request PM IO registers: %d\n",
res);
return res;
}

pm_dev = dev;
io_offset = pci_resource_start(dev, piix4_pm_io_region);
pm_power_off = piix4_poweroff;

return 0;
}

static void piix4_poweroff_remove(struct pci_dev *dev)
{
if (pm_power_off == piix4_poweroff)
pm_power_off = NULL;

pci_release_region(dev, piix4_pm_io_region);
pm_dev = NULL;
}

static const struct pci_device_id piix4_poweroff_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) },
{ 0 },
};

static struct pci_driver piix4_poweroff_driver = {
.name = "piix4-poweroff",
.id_table = piix4_poweroff_ids,
.probe = piix4_poweroff_probe,
.remove = piix4_poweroff_remove,
};

module_pci_driver(piix4_poweroff_driver);
MODULE_AUTHOR("Paul Burton <paul.burton@imgtec.com>");
MODULE_LICENSE("GPL");
1 change: 1 addition & 0 deletions drivers/power/reset/syscon-reboot-mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ static const struct of_device_id syscon_reboot_mode_of_match[] = {
{ .compatible = "syscon-reboot-mode" },
{}
};
MODULE_DEVICE_TABLE(of, syscon_reboot_mode_of_match);

static struct platform_driver syscon_reboot_mode_driver = {
.probe = syscon_reboot_mode_probe,
Expand Down
1 change: 1 addition & 0 deletions drivers/power/reset/zx-reboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static const struct of_device_id zx_reboot_of_match[] = {
{ .compatible = "zte,sysctrl" },
{}
};
MODULE_DEVICE_TABLE(of, zx_reboot_of_match);

static struct platform_driver zx_reboot_driver = {
.probe = zx_reboot_probe,
Expand Down
8 changes: 4 additions & 4 deletions drivers/power/supply/ab8500_fg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@ static void ab8500_fg_low_bat_work(struct work_struct *work)
* ab8500_fg_battok_calc - calculate the bit pattern corresponding
* to the target voltage.
* @di: pointer to the ab8500_fg structure
* @target target voltage
* @target: target voltage
*
* Returns bit pattern closest to the target voltage
* valid return values are 0-14. (0-BATT_OK_MAX_NR_INCREMENTS)
Expand Down Expand Up @@ -2391,7 +2391,7 @@ static void ab8500_fg_external_power_changed(struct power_supply *psy)
}

/**
* abab8500_fg_reinit_work() - work to reset the FG algorithm
* ab8500_fg_reinit_work() - work to reset the FG algorithm
* @work: pointer to the work_struct structure
*
* Used to reset the current battery capacity to be able to
Expand Down Expand Up @@ -2528,7 +2528,7 @@ static struct kobj_type ab8500_fg_ktype = {
};

/**
* ab8500_chargalg_sysfs_exit() - de-init of sysfs entry
* ab8500_fg_sysfs_exit() - de-init of sysfs entry
* @di: pointer to the struct ab8500_chargalg
*
* This function removes the entry in sysfs.
Expand All @@ -2539,7 +2539,7 @@ static void ab8500_fg_sysfs_exit(struct ab8500_fg *di)
}

/**
* ab8500_chargalg_sysfs_init() - init of sysfs entry
* ab8500_fg_sysfs_init() - init of sysfs entry
* @di: pointer to the struct ab8500_chargalg
*
* This function adds an entry in sysfs.
Expand Down
1 change: 1 addition & 0 deletions drivers/power/supply/axp288_fuel_gauge.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,7 @@ static const struct platform_device_id axp288_fg_id_table[] = {
{ .name = DEV_NAME },
{},
};
MODULE_DEVICE_TABLE(platform, axp288_fg_id_table);

static int axp288_fuel_gauge_remove(struct platform_device *pdev)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/supply/bq24190_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ static int bq24190_battery_set_property(struct power_supply *psy,

dev_dbg(bdi->dev, "prop: %d\n", psp);

pm_runtime_put_sync(bdi->dev);
pm_runtime_get_sync(bdi->dev);

switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
Expand Down
44 changes: 42 additions & 2 deletions drivers/power/supply/bq27xxx_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,25 @@ static u8 bq27xxx_regs[][BQ27XXX_REG_MAX] = {
[BQ27XXX_REG_DCAP] = 0x3c,
[BQ27XXX_REG_AP] = INVALID_REG_ADDR,
},
[BQ27510] = {
[BQ27XXX_REG_CTRL] = 0x00,
[BQ27XXX_REG_TEMP] = 0x06,
[BQ27XXX_REG_INT_TEMP] = 0x28,
[BQ27XXX_REG_VOLT] = 0x08,
[BQ27XXX_REG_AI] = 0x14,
[BQ27XXX_REG_FLAGS] = 0x0a,
[BQ27XXX_REG_TTE] = 0x16,
[BQ27XXX_REG_TTF] = INVALID_REG_ADDR,
[BQ27XXX_REG_TTES] = 0x1a,
[BQ27XXX_REG_TTECP] = INVALID_REG_ADDR,
[BQ27XXX_REG_NAC] = 0x0c,
[BQ27XXX_REG_FCC] = 0x12,
[BQ27XXX_REG_CYCT] = 0x1e,
[BQ27XXX_REG_AE] = INVALID_REG_ADDR,
[BQ27XXX_REG_SOC] = 0x20,
[BQ27XXX_REG_DCAP] = 0x2e,
[BQ27XXX_REG_AP] = INVALID_REG_ADDR,
},
[BQ27530] = {
[BQ27XXX_REG_CTRL] = 0x00,
[BQ27XXX_REG_TEMP] = 0x06,
Expand Down Expand Up @@ -302,6 +321,24 @@ static enum power_supply_property bq27500_battery_props[] = {
POWER_SUPPLY_PROP_MANUFACTURER,
};

static enum power_supply_property bq27510_battery_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_CURRENT_NOW,
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
POWER_SUPPLY_PROP_TEMP,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_CHARGE_FULL,
POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_MANUFACTURER,
};

static enum power_supply_property bq27530_battery_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_PRESENT,
Expand Down Expand Up @@ -385,6 +422,7 @@ static struct {
BQ27XXX_PROP(BQ27000, bq27000_battery_props),
BQ27XXX_PROP(BQ27010, bq27010_battery_props),
BQ27XXX_PROP(BQ27500, bq27500_battery_props),
BQ27XXX_PROP(BQ27510, bq27510_battery_props),
BQ27XXX_PROP(BQ27530, bq27530_battery_props),
BQ27XXX_PROP(BQ27541, bq27541_battery_props),
BQ27XXX_PROP(BQ27545, bq27545_battery_props),
Expand All @@ -397,10 +435,11 @@ 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;
unsigned int prev_val = *(unsigned int *) kp->arg;
int ret;

ret = param_set_uint(val, kp);
if (ret < 0)
if (ret < 0 || prev_val == *(unsigned int *) kp->arg)
return ret;

mutex_lock(&bq27xxx_list_lock);
Expand Down Expand Up @@ -635,7 +674,8 @@ static int bq27xxx_battery_read_pwr_avg(struct bq27xxx_device_info *di)
*/
static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags)
{
if (di->chip == BQ27500 || di->chip == BQ27541 || di->chip == BQ27545)
if (di->chip == BQ27500 || di->chip == BQ27510 ||
di->chip == BQ27541 || di->chip == BQ27545)
return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD);
if (di->chip == BQ27530 || di->chip == BQ27421)
return flags & BQ27XXX_FLAG_OT;
Expand Down
4 changes: 2 additions & 2 deletions drivers/power/supply/bq27xxx_battery_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = {
{ "bq27200", BQ27000 },
{ "bq27210", BQ27010 },
{ "bq27500", BQ27500 },
{ "bq27510", BQ27500 },
{ "bq27520", BQ27500 },
{ "bq27510", BQ27510 },
{ "bq27520", BQ27510 },
{ "bq27530", BQ27530 },
{ "bq27531", BQ27530 },
{ "bq27541", BQ27541 },
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/supply/ipaq_micro_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,4 @@ module_platform_driver(micro_batt_device_driver);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("driver for iPAQ Atmel micro battery");
MODULE_ALIAS("platform:battery-ipaq-micro");
MODULE_ALIAS("platform:ipaq-micro-battery");
3 changes: 0 additions & 3 deletions drivers/power/supply/lp8788-charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,6 @@ static int lp8788_update_charger_params(struct platform_device *pdev,
for (i = 0; i < pdata->num_chg_params; i++) {
param = pdata->chg_params + i;

if (!param)
continue;

if (lp8788_is_valid_charger_register(param->addr)) {
ret = lp8788_write_byte(lp, param->addr, param->val);
if (ret)
Expand Down
Loading

0 comments on commit bbcd9c5

Please sign in to comment.