mirror of https://gitee.com/openkylin/linux.git
power supply and reset changes for the v4.10 series
* New driver for Intel PIIX4 * lots of module autoload fixes * misc. fixes -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlhRSwwACgkQ2O7X88g7 +ppsxQ/7BMBtkVlr2lLFfognswP87r6cqeEhKICpxbgk1KfcTG7xJ/AEyPUDflET htPTurpcetlJLB1057ikSt9QTMtyIBUgpbnM+oJt0EVj/UYV6mXw6rqkNX/ROfVY JcIN1/nQljv3W//tR83x04TJv+8V65lV/Jrh3XkNS2arRXCD/JktRNljvgUpn2iw Tp9MM8eyv9J4VN5BCPudyBOU0Y6ztC9VVDj/p+I7giUOm3udAvgYvcOTqBdCcuZH ThDnf8dLNWmTkLTWqPBCnmfe2TyS8IbWMYMtYec3E5NzymzuYA1r0U1wBRVLm4BA LFeEXLtmRx3pXt6YY2MqPF9jQGhMsiDdKhHmF0GhpofEk1Ctu0xzCyvA1wxtLq/I bt006d5tu1Y+yFu1t0iPCEtGP5H2dt1p9Rq4EM7rgEodIsolIdD5h/Fdc3g7IdRK 1HgkKhzEOT4+WrIyT3HoI8k8lgFmYs8BumbLTYIR6j/XD8ZBO8Dk4pljyL3B4lur qszI73U1yp5iEq4/Mcam1LHwfOxt7liYPrqDiZgUDuK3QAy4Z2lQTjXbaEaTCgN9 Z5YUSh9RrCTYhAcy5zNEeoixfnDxB7G09v7+5Cfh4RJnZZ2tBL5sQSbMZMgTjbRT Trbupf9z7ItYNRerEm+2vSgOTkQpj2V6SaP+jrEl/il0/UDLVoo= =s+mK -----END PGP SIGNATURE----- Merge tag 'for-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/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
This commit is contained in:
commit
bbcd9c53c7
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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,
|
||||
|
@ -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),
|
||||
|
|
|
@ -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");
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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),
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -21,18 +21,13 @@
|
|||
#include <linux/max17040_battery.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#define MAX17040_VCELL_MSB 0x02
|
||||
#define MAX17040_VCELL_LSB 0x03
|
||||
#define MAX17040_SOC_MSB 0x04
|
||||
#define MAX17040_SOC_LSB 0x05
|
||||
#define MAX17040_MODE_MSB 0x06
|
||||
#define MAX17040_MODE_LSB 0x07
|
||||
#define MAX17040_VER_MSB 0x08
|
||||
#define MAX17040_VER_LSB 0x09
|
||||
#define MAX17040_RCOMP_MSB 0x0C
|
||||
#define MAX17040_RCOMP_LSB 0x0D
|
||||
#define MAX17040_CMD_MSB 0xFE
|
||||
#define MAX17040_CMD_LSB 0xFF
|
||||
#define MAX17040_VCELL 0x02
|
||||
#define MAX17040_SOC 0x04
|
||||
#define MAX17040_MODE 0x06
|
||||
#define MAX17040_VER 0x08
|
||||
#define MAX17040_RCOMP 0x0C
|
||||
#define MAX17040_CMD 0xFE
|
||||
|
||||
|
||||
#define MAX17040_DELAY 1000
|
||||
#define MAX17040_BATTERY_FULL 95
|
||||
|
@ -78,11 +73,11 @@ static int max17040_get_property(struct power_supply *psy,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int max17040_write_reg(struct i2c_client *client, int reg, u8 value)
|
||||
static int max17040_write_reg(struct i2c_client *client, int reg, u16 value)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = i2c_smbus_write_byte_data(client, reg, value);
|
||||
ret = i2c_smbus_write_word_swapped(client, reg, value);
|
||||
|
||||
if (ret < 0)
|
||||
dev_err(&client->dev, "%s: err %d\n", __func__, ret);
|
||||
|
@ -94,7 +89,7 @@ static int max17040_read_reg(struct i2c_client *client, int reg)
|
|||
{
|
||||
int ret;
|
||||
|
||||
ret = i2c_smbus_read_byte_data(client, reg);
|
||||
ret = i2c_smbus_read_word_swapped(client, reg);
|
||||
|
||||
if (ret < 0)
|
||||
dev_err(&client->dev, "%s: err %d\n", __func__, ret);
|
||||
|
@ -104,43 +99,36 @@ static int max17040_read_reg(struct i2c_client *client, int reg)
|
|||
|
||||
static void max17040_reset(struct i2c_client *client)
|
||||
{
|
||||
max17040_write_reg(client, MAX17040_CMD_MSB, 0x54);
|
||||
max17040_write_reg(client, MAX17040_CMD_LSB, 0x00);
|
||||
max17040_write_reg(client, MAX17040_CMD, 0x0054);
|
||||
}
|
||||
|
||||
static void max17040_get_vcell(struct i2c_client *client)
|
||||
{
|
||||
struct max17040_chip *chip = i2c_get_clientdata(client);
|
||||
u8 msb;
|
||||
u8 lsb;
|
||||
u16 vcell;
|
||||
|
||||
msb = max17040_read_reg(client, MAX17040_VCELL_MSB);
|
||||
lsb = max17040_read_reg(client, MAX17040_VCELL_LSB);
|
||||
vcell = max17040_read_reg(client, MAX17040_VCELL);
|
||||
|
||||
chip->vcell = (msb << 4) + (lsb >> 4);
|
||||
chip->vcell = vcell;
|
||||
}
|
||||
|
||||
static void max17040_get_soc(struct i2c_client *client)
|
||||
{
|
||||
struct max17040_chip *chip = i2c_get_clientdata(client);
|
||||
u8 msb;
|
||||
u8 lsb;
|
||||
u16 soc;
|
||||
|
||||
msb = max17040_read_reg(client, MAX17040_SOC_MSB);
|
||||
lsb = max17040_read_reg(client, MAX17040_SOC_LSB);
|
||||
soc = max17040_read_reg(client, MAX17040_SOC);
|
||||
|
||||
chip->soc = msb;
|
||||
chip->soc = (soc >> 8);
|
||||
}
|
||||
|
||||
static void max17040_get_version(struct i2c_client *client)
|
||||
{
|
||||
u8 msb;
|
||||
u8 lsb;
|
||||
u16 version;
|
||||
|
||||
msb = max17040_read_reg(client, MAX17040_VER_MSB);
|
||||
lsb = max17040_read_reg(client, MAX17040_VER_LSB);
|
||||
version = max17040_read_reg(client, MAX17040_VER);
|
||||
|
||||
dev_info(&client->dev, "MAX17040 Fuel-Gauge Ver %d%d\n", msb, lsb);
|
||||
dev_info(&client->dev, "MAX17040 Fuel-Gauge Ver 0x%x\n", version);
|
||||
}
|
||||
|
||||
static void max17040_get_online(struct i2c_client *client)
|
||||
|
|
|
@ -184,6 +184,7 @@ static const struct platform_device_id max8997_battery_id[] = {
|
|||
{ "max8997-battery", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(platform, max8997_battery_id);
|
||||
|
||||
static struct platform_driver max8997_battery_driver = {
|
||||
.driver = {
|
||||
|
|
|
@ -413,7 +413,7 @@ static int power_supply_match_device_node(struct device *dev, const void *data)
|
|||
/**
|
||||
* power_supply_get_by_phandle() - Search for a power supply and returns its ref
|
||||
* @np: Pointer to device node holding phandle property
|
||||
* @phandle_name: Name of property holding a power supply name
|
||||
* @property: Name of property holding a power supply name
|
||||
*
|
||||
* If power supply was found, it increases reference count for the
|
||||
* internal power supply's device. The user should power_supply_put()
|
||||
|
@ -458,7 +458,7 @@ static void devm_power_supply_put(struct device *dev, void *res)
|
|||
* devm_power_supply_get_by_phandle() - Resource managed version of
|
||||
* power_supply_get_by_phandle()
|
||||
* @dev: Pointer to device holding phandle property
|
||||
* @phandle_name: Name of property holding a power supply phandle
|
||||
* @property: Name of property holding a power supply phandle
|
||||
*
|
||||
* Return: On success returns a reference to a power supply with
|
||||
* matching name equals to value under @property, NULL or ERR_PTR otherwise.
|
||||
|
|
|
@ -182,7 +182,7 @@ static ssize_t charger_state_show(struct device *dev,
|
|||
return sprintf(buf, "%s\n", charge);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(charger_state, 0444, charger_state_show, NULL);
|
||||
static DEVICE_ATTR_RO(charger_state);
|
||||
|
||||
static irqreturn_t wm8350_charger_handler(int irq, void *data)
|
||||
{
|
||||
|
|
|
@ -30,8 +30,7 @@ static enum power_supply_property *prop;
|
|||
|
||||
static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
|
||||
{
|
||||
struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data;
|
||||
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
|
||||
struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
|
||||
|
||||
return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev.parent),
|
||||
pdata->batt_aux) * pdata->batt_mult /
|
||||
|
@ -40,8 +39,7 @@ static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
|
|||
|
||||
static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
|
||||
{
|
||||
struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data;
|
||||
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
|
||||
struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
|
||||
|
||||
return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev.parent),
|
||||
pdata->temp_aux) * pdata->temp_mult /
|
||||
|
@ -52,8 +50,7 @@ static int wm97xx_bat_get_property(struct power_supply *bat_ps,
|
|||
enum power_supply_property psp,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data;
|
||||
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
|
||||
struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
|
||||
|
||||
switch (psp) {
|
||||
case POWER_SUPPLY_PROP_STATUS:
|
||||
|
@ -103,8 +100,7 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
|
|||
static void wm97xx_bat_update(struct power_supply *bat_ps)
|
||||
{
|
||||
int old_status = bat_status;
|
||||
struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data;
|
||||
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
|
||||
struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps);
|
||||
|
||||
mutex_lock(&work_lock);
|
||||
|
||||
|
@ -166,15 +162,15 @@ static int wm97xx_bat_probe(struct platform_device *dev)
|
|||
int ret = 0;
|
||||
int props = 1; /* POWER_SUPPLY_PROP_PRESENT */
|
||||
int i = 0;
|
||||
struct wm97xx_pdata *wmdata = dev->dev.platform_data;
|
||||
struct wm97xx_batt_pdata *pdata;
|
||||
struct wm97xx_batt_pdata *pdata = dev->dev.platform_data;
|
||||
struct power_supply_config cfg = {};
|
||||
|
||||
if (!wmdata) {
|
||||
if (!pdata) {
|
||||
dev_err(&dev->dev, "No platform data supplied\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pdata = wmdata->batt_pdata;
|
||||
cfg.drv_data = pdata;
|
||||
|
||||
if (dev->id != -1)
|
||||
return -EINVAL;
|
||||
|
@ -243,7 +239,7 @@ static int wm97xx_bat_probe(struct platform_device *dev)
|
|||
bat_psy_desc.properties = prop;
|
||||
bat_psy_desc.num_properties = props;
|
||||
|
||||
bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, NULL);
|
||||
bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, &cfg);
|
||||
if (!IS_ERR(bat_psy)) {
|
||||
schedule_work(&bat_work);
|
||||
} else {
|
||||
|
@ -266,8 +262,7 @@ static int wm97xx_bat_probe(struct platform_device *dev)
|
|||
|
||||
static int wm97xx_bat_remove(struct platform_device *dev)
|
||||
{
|
||||
struct wm97xx_pdata *wmdata = dev->dev.platform_data;
|
||||
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
|
||||
struct wm97xx_batt_pdata *pdata = dev->dev.platform_data;
|
||||
|
||||
if (pdata && gpio_is_valid(pdata->charge_gpio)) {
|
||||
free_irq(gpio_to_irq(pdata->charge_gpio), dev);
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
enum bq27xxx_chip {
|
||||
BQ27000 = 1, /* bq27000, bq27200 */
|
||||
BQ27010, /* bq27010, bq27210 */
|
||||
BQ27500, /* bq27500, bq27510, bq27520 */
|
||||
BQ27500, /* bq27500 */
|
||||
BQ27510, /* bq27510, bq27520 */
|
||||
BQ27530, /* bq27530, bq27531 */
|
||||
BQ27541, /* bq27541, bq27542, bq27546, bq27742 */
|
||||
BQ27545, /* bq27545 */
|
||||
|
|
Loading…
Reference in New Issue