Commit 13c07190 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-v3.20' of git://git.infradead.org/battery-2.6

Pull power supply and reset changes from Sebastian Reichel:
 "New drivers:
   - charger driver for Maxim 77693
   - battery gauge driver for LTC 2941/2943
   - battery gauge driver for RT5033
   - reset driver for R-Mobile platforms

  Convert drivers to restart handler framework:
   - arm-versatile
   - at91
   - st-poweroff

  Misc:
   - remove deprecated sun6i reboot driver
   - use alarmtimer instead of rtc in charger-manager
   - misc fixes"

* tag 'for-v3.20' of git://git.infradead.org/battery-2.6: (48 commits)
  power_supply: 88pm860x: Fix leaked power supply on probe fail
  power/reset: restart-poweroff: Remove arm dependencies
  power/reset: st-poweroff: Fix misleading Kconfig description
  power/reset: st-poweroff: Register with kernel restart handler
  power/reset: Remove sun6i reboot driver
  power/reset: at91: Register with kernel restart handler
  power/reset: arm-versatile: Register with kernel restart handler
  power: test_power: Use enum as index for array of supplies
  Add devicetree binding documentation for the LTC2941/LTC2943 driver
  Add LTC2941/LTC2943 Battery Gauge Driver
  power/reset: brcmstb: Add support for old 65nm chips
  power/reset: brcmstb: Use the DT "compatible" string to indicate bit positions
  power/reset: brcmstb: Make the driver buildable on MIPS
  power: charger-manager: Use alarmtimer for battery monitoring in suspend.
  power/reset: at91-poweroff: Fix error handling and other compiler warnings
  bq27x00_battery: Call power_supply_changed only when capacity changed
  bq27x00_battery: fix register offset for bq27425
  power: max14577: Remove SYSFS dependency from Kconfig
  power: bq24190_charger: suppress build warning
  power: reset: Add reset driver for R-Mobile platforms
  ...
parents c5ce28df 24727b45
...@@ -32,3 +32,45 @@ Description: ...@@ -32,3 +32,45 @@ Description:
Valid values: Valid values:
- 5, 6 or 7 (hours), - 5, 6 or 7 (hours),
- 0: disabled. - 0: disabled.
What: /sys/class/power_supply/max77693-charger/device/fast_charge_timer
Date: January 2015
KernelVersion: 3.19.0
Contact: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Description:
This entry shows and sets the maximum time the max77693
charger operates in fast-charge mode. When the timer expires
the device will terminate fast-charge mode (charging current
will drop to 0 A) and will trigger interrupt.
Valid values:
- 4 - 16 (hours), step by 2 (rounded down)
- 0: disabled.
What: /sys/class/power_supply/max77693-charger/device/top_off_threshold_current
Date: January 2015
KernelVersion: 3.19.0
Contact: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Description:
This entry shows and sets the charging current threshold for
entering top-off charging mode. When charging current in fast
charge mode drops below this value, the charger will trigger
interrupt and start top-off charging mode.
Valid values:
- 100000 - 200000 (microamps), step by 25000 (rounded down)
- 200000 - 350000 (microamps), step by 50000 (rounded down)
- 0: disabled.
What: /sys/class/power_supply/max77693-charger/device/top_off_timer
Date: January 2015
KernelVersion: 3.19.0
Contact: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Description:
This entry shows and sets the maximum time the max77693
charger operates in top-off charge mode. When the timer expires
the device will terminate top-off charge mode (charging current
will drop to 0 A) and will trigger interrupt.
Valid values:
- 0 - 70 (minutes), step by 10 (rounded down)
...@@ -79,7 +79,9 @@ reboot ...@@ -79,7 +79,9 @@ reboot
Required properties Required properties
- compatible - compatible
The string property "brcm,brcmstb-reboot". The string property "brcm,brcmstb-reboot" for 40nm/28nm chips with
the new SYS_CTRL interface, or "brcm,bcm7038-reboot" for 65nm
chips with the old SUN_TOP_CTRL interface.
- syscon - syscon
A phandle / integer array that points to the syscon node which describes A phandle / integer array that points to the syscon node which describes
......
...@@ -41,6 +41,41 @@ Optional properties: ...@@ -41,6 +41,41 @@ Optional properties:
To get more informations, please refer to documentaion. To get more informations, please refer to documentaion.
[*] refer Documentation/devicetree/bindings/pwm/pwm.txt [*] refer Documentation/devicetree/bindings/pwm/pwm.txt
- charger : Node configuring the charger driver.
If present, required properties:
- compatible : Must be "maxim,max77693-charger".
Optional properties (if not set, defaults will be used):
- maxim,constant-microvolt : Battery constant voltage in uV. The charger
will operate in fast charge constant current mode till battery voltage
reaches this level. Then the charger will switch to fast charge constant
voltage mode. Also vsys (system voltage) will be set to this value when
DC power is supplied but charger is not enabled.
Valid values: 3650000 - 4400000, step by 25000 (rounded down)
Default: 4200000
- maxim,min-system-microvolt : Minimal system voltage in uV.
Valid values: 3000000 - 3700000, step by 100000 (rounded down)
Default: 3600000
- maxim,thermal-regulation-celsius : Temperature in Celsius for entering
high temperature charging mode. If die temperature exceeds this value
the charging current will be reduced by 105 mA/Celsius.
Valid values: 70, 85, 100, 115
Default: 100
- maxim,battery-overcurrent-microamp : Overcurrent protection threshold
in uA (current from battery to system).
Valid values: 2000000 - 3500000, step by 250000 (rounded down)
Default: 3500000
- maxim,charge-input-threshold-microvolt : Threshold voltage in uV for
triggering input voltage regulation loop. If input voltage decreases
below this value, the input current will be reduced to reach the
threshold voltage.
Valid values: 4300000, 4700000, 4800000, 4900000
Default: 4300000
Example: Example:
max77693@66 { max77693@66 {
compatible = "maxim,max77693"; compatible = "maxim,max77693";
...@@ -73,4 +108,14 @@ Example: ...@@ -73,4 +108,14 @@ Example:
pwms = <&pwm 0 40000 0>; pwms = <&pwm 0 40000 0>;
pwm-names = "haptic"; pwm-names = "haptic";
}; };
charger {
compatible = "maxim,max77693-charger";
maxim,constant-microvolt = <4200000>;
maxim,min-system-microvolt = <3600000>;
maxim,thermal-regulation-celsius = <75>;
maxim,battery-overcurrent-microamp = <3000000>;
maxim,charge-input-threshold-microvolt = <4300000>;
};
}; };
binding for LTC2941 and LTC2943 battery gauges
Both the LTC2941 and LTC2943 measure battery capacity.
The LTC2943 is compatible with the LTC2941, it adds voltage and
temperature monitoring, and uses a slightly different conversion
formula for the charge counter.
Required properties:
- compatible: Should contain "ltc2941" or "ltc2943" which also indicates the
type of I2C chip attached.
- reg: The 7-bit I2C address.
- lltc,resistor-sense: The sense resistor value in milli-ohms. Can be a 32-bit
negative value when the battery has been connected to the wrong end of the
resistor.
- lltc,prescaler-exponent: The prescaler exponent as explained in the datasheet.
This determines the range and accuracy of the gauge. The value is programmed
into the chip only if it differs from the current setting. The setting is
lost when the battery is disconnected.
Example from the Topic Miami Florida board:
fuelgauge: ltc2943@64 {
compatible = "ltc2943";
reg = <0x64>;
lltc,resistor-sense = <15>;
lltc,prescaler-exponent = <5>; /* 2^(2*5) = 1024 */
};
Binding for the LTC2952 PowerPath controller Binding for the LTC2952 PowerPath controller
This chip is used to externally trigger a system shut down. Once the trigger has This chip is used to externally trigger a system shut down. Once the trigger has
been sent, the chips' watchdog has to be reset to gracefully shut down. been sent, the chip's watchdog has to be reset to gracefully shut down.
If the Linux systems decides to shut down it powers off the platform via the A full powerdown can be triggered via the kill signal.
kill signal.
Required properties: Required properties:
- compatible: Must contain: "lltc,ltc2952" - compatible: Must contain: "lltc,ltc2952"
- trigger-gpios: phandle + gpio-specifier for the GPIO connected to the
chip's trigger line
- watchdog-gpios: phandle + gpio-specifier for the GPIO connected to the - watchdog-gpios: phandle + gpio-specifier for the GPIO connected to the
chip's watchdog line chip's watchdog line
- kill-gpios: phandle + gpio-specifier for the GPIO connected to the - kill-gpios: phandle + gpio-specifier for the GPIO connected to the
chip's kill line chip's kill line
Optional properties:
- trigger-gpios: phandle + gpio-specifier for the GPIO connected to the
chip's trigger line. If this property is not set, the
trigger function is ignored and the chip is kept alive
until an explicit kill signal is received
Example: Example:
ltc2952 { ltc2952 {
......
...@@ -6165,6 +6165,13 @@ F: Documentation/devicetree/bindings/i2c/max6697.txt ...@@ -6165,6 +6165,13 @@ F: Documentation/devicetree/bindings/i2c/max6697.txt
F: drivers/hwmon/max6697.c F: drivers/hwmon/max6697.c
F: include/linux/platform_data/max6697.h F: include/linux/platform_data/max6697.h
MAXIM MUIC CHARGER DRIVERS FOR EXYNOS BASED BOARDS
M: Krzysztof Kozlowski <k.kozlowski@samsung.com>
L: linux-pm@vger.kernel.org
S: Supported
F: drivers/power/max14577_charger.c
F: drivers/power/max77693_charger.c
MAXIRADIO FM RADIO RECEIVER DRIVER MAXIRADIO FM RADIO RECEIVER DRIVER
M: Hans Verkuil <hverkuil@xs4all.nl> M: Hans Verkuil <hverkuil@xs4all.nl>
L: linux-media@vger.kernel.org L: linux-media@vger.kernel.org
......
...@@ -711,6 +711,7 @@ static int pm860x_charger_probe(struct platform_device *pdev) ...@@ -711,6 +711,7 @@ static int pm860x_charger_probe(struct platform_device *pdev)
return 0; return 0;
out_irq: out_irq:
power_supply_unregister(&info->usb);
while (--i >= 0) while (--i >= 0)
free_irq(info->irq[i], info); free_irq(info->irq[i], info);
out: out:
......
...@@ -315,7 +315,7 @@ config CHARGER_GPIO ...@@ -315,7 +315,7 @@ config CHARGER_GPIO
config CHARGER_MANAGER config CHARGER_MANAGER
bool "Battery charger manager for multiple chargers" bool "Battery charger manager for multiple chargers"
depends on REGULATOR && RTC_CLASS depends on REGULATOR
select EXTCON select EXTCON
help help
Say Y to enable charger-manager support, which allows multiple Say Y to enable charger-manager support, which allows multiple
...@@ -327,11 +327,16 @@ config CHARGER_MANAGER ...@@ -327,11 +327,16 @@ config CHARGER_MANAGER
config CHARGER_MAX14577 config CHARGER_MAX14577
tristate "Maxim MAX14577/77836 battery charger driver" tristate "Maxim MAX14577/77836 battery charger driver"
depends on MFD_MAX14577 depends on MFD_MAX14577
depends on SYSFS
help help
Say Y to enable support for the battery charger control sysfs and Say Y to enable support for the battery charger control sysfs and
platform data of MAX14577/77836 MUICs. 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 config CHARGER_MAX8997
tristate "Maxim MAX8997/MAX8966 PMIC battery charger driver" tristate "Maxim MAX8997/MAX8966 PMIC battery charger driver"
depends on MFD_MAX8997 && REGULATOR_MAX8997 depends on MFD_MAX8997 && REGULATOR_MAX8997
...@@ -383,6 +388,14 @@ config CHARGER_TPS65090 ...@@ -383,6 +388,14 @@ config CHARGER_TPS65090
Say Y here to enable support for battery charging with TPS65090 Say Y here to enable support for battery charging with TPS65090
PMIC chips. 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 config AB8500_BM
bool "AB8500 Battery Management Driver" bool "AB8500 Battery Management Driver"
depends on AB8500_CORE && AB8500_GPADC depends on AB8500_CORE && AB8500_GPADC
...@@ -397,6 +410,14 @@ config BATTERY_GOLDFISH ...@@ -397,6 +410,14 @@ config BATTERY_GOLDFISH
Say Y to enable support for the battery and AC power in the Say Y to enable support for the battery and AC power in the
Goldfish emulator. 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.
source "drivers/power/reset/Kconfig" source "drivers/power/reset/Kconfig"
endif # POWER_SUPPLY endif # POWER_SUPPLY
......
...@@ -20,6 +20,7 @@ obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o ...@@ -20,6 +20,7 @@ obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o
obj-$(CONFIG_BATTERY_DS2780) += ds2780_battery.o obj-$(CONFIG_BATTERY_DS2780) += ds2780_battery.o
obj-$(CONFIG_BATTERY_DS2781) += ds2781_battery.o obj-$(CONFIG_BATTERY_DS2781) += ds2781_battery.o
obj-$(CONFIG_BATTERY_DS2782) += ds2782_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_GOLDFISH) += goldfish_battery.o
obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o
obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o
...@@ -34,6 +35,7 @@ obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o ...@@ -34,6 +35,7 @@ obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o
obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o
obj-$(CONFIG_BATTERY_Z2) += z2_battery.o obj-$(CONFIG_BATTERY_Z2) += z2_battery.o
obj-$(CONFIG_BATTERY_RT5033) += rt5033_battery.o
obj-$(CONFIG_BATTERY_S3C_ADC) += s3c_adc_battery.o obj-$(CONFIG_BATTERY_S3C_ADC) += s3c_adc_battery.o
obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
...@@ -50,6 +52,7 @@ obj-$(CONFIG_CHARGER_LP8788) += lp8788-charger.o ...@@ -50,6 +52,7 @@ obj-$(CONFIG_CHARGER_LP8788) += lp8788-charger.o
obj-$(CONFIG_CHARGER_GPIO) += gpio-charger.o obj-$(CONFIG_CHARGER_GPIO) += gpio-charger.o
obj-$(CONFIG_CHARGER_MANAGER) += charger-manager.o obj-$(CONFIG_CHARGER_MANAGER) += charger-manager.o
obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.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_MAX8997) += max8997_charger.o
obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o
obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
......
...@@ -2435,20 +2435,6 @@ static void ab8500_fg_reinit_work(struct work_struct *work) ...@@ -2435,20 +2435,6 @@ static void ab8500_fg_reinit_work(struct work_struct *work)
} }
} }
/**
* ab8500_fg_reinit() - forces FG algorithm to reinitialize with current values
*
* This function can be used to force the FG algorithm to recalculate a new
* voltage based battery capacity.
*/
void ab8500_fg_reinit(void)
{
struct ab8500_fg *di = ab8500_fg_get();
/* User won't be notified if a null pointer returned. */
if (di != NULL)
queue_delayed_work(di->fg_wq, &di->fg_reinit_work, 0);
}
/* Exposure to the sysfs interface */ /* Exposure to the sysfs interface */
struct ab8500_fg_sysfs_entry { struct ab8500_fg_sysfs_entry {
......
...@@ -929,7 +929,7 @@ static void bq24190_charger_init(struct power_supply *charger) ...@@ -929,7 +929,7 @@ static void bq24190_charger_init(struct power_supply *charger)
charger->properties = bq24190_charger_properties; charger->properties = bq24190_charger_properties;
charger->num_properties = ARRAY_SIZE(bq24190_charger_properties); charger->num_properties = ARRAY_SIZE(bq24190_charger_properties);
charger->supplied_to = bq24190_charger_supplied_to; charger->supplied_to = bq24190_charger_supplied_to;
charger->num_supplies = ARRAY_SIZE(bq24190_charger_supplied_to); charger->num_supplicants = ARRAY_SIZE(bq24190_charger_supplied_to);
charger->get_property = bq24190_charger_get_property; charger->get_property = bq24190_charger_get_property;
charger->set_property = bq24190_charger_set_property; charger->set_property = bq24190_charger_set_property;
charger->property_is_writeable = bq24190_charger_property_is_writeable; charger->property_is_writeable = bq24190_charger_property_is_writeable;
...@@ -1208,7 +1208,7 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data) ...@@ -1208,7 +1208,7 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
{ {
struct bq24190_dev_info *bdi = data; struct bq24190_dev_info *bdi = data;
bool alert_userspace = false; bool alert_userspace = false;
u8 ss_reg, f_reg; u8 ss_reg = 0, f_reg = 0;
int ret; int ret;
pm_runtime_get_sync(bdi->dev); pm_runtime_get_sync(bdi->dev);
......
...@@ -76,7 +76,8 @@ ...@@ -76,7 +76,8 @@
/* bq27425 register addresses are same as bq27x00 addresses minus 4 */ /* bq27425 register addresses are same as bq27x00 addresses minus 4 */
#define BQ27425_REG_OFFSET 0x04 #define BQ27425_REG_OFFSET 0x04
#define BQ27425_REG_SOC 0x18 /* Register address plus offset */ #define BQ27425_REG_SOC (0x1C + BQ27425_REG_OFFSET)
#define BQ27425_REG_DCAP (0x3C + BQ27425_REG_OFFSET)
#define BQ27000_RS 20 /* Resistor sense */ #define BQ27000_RS 20 /* Resistor sense */
#define BQ27x00_POWER_CONSTANT (256 * 29200 / 1000) #define BQ27x00_POWER_CONSTANT (256 * 29200 / 1000)
...@@ -282,9 +283,12 @@ static int bq27x00_battery_read_ilmd(struct bq27x00_device_info *di) ...@@ -282,9 +283,12 @@ static int bq27x00_battery_read_ilmd(struct bq27x00_device_info *di)
{ {
int ilmd; int ilmd;
if (bq27xxx_is_chip_version_higher(di)) if (bq27xxx_is_chip_version_higher(di)) {
ilmd = bq27x00_read(di, BQ27500_REG_DCAP, false); if (di->chip == BQ27425)
ilmd = bq27x00_read(di, BQ27425_REG_DCAP, false);
else else
ilmd = bq27x00_read(di, BQ27500_REG_DCAP, false);
} else
ilmd = bq27x00_read(di, BQ27000_REG_ILMD, true); ilmd = bq27x00_read(di, BQ27000_REG_ILMD, true);
if (ilmd < 0) { if (ilmd < 0) {
...@@ -493,10 +497,11 @@ static void bq27x00_update(struct bq27x00_device_info *di) ...@@ -493,10 +497,11 @@ static void bq27x00_update(struct bq27x00_device_info *di)
di->charge_design_full = bq27x00_battery_read_ilmd(di); di->charge_design_full = bq27x00_battery_read_ilmd(di);
} }
if (memcmp(&di->cache, &cache, sizeof(cache)) != 0) { if (di->cache.capacity != cache.capacity)
di->cache = cache;
power_supply_changed(&di->bat); power_supply_changed(&di->bat);
}
if (memcmp(&di->cache, &cache, sizeof(cache)) != 0)
di->cache = cache;
di->last_update = jiffies; di->last_update = jiffies;
} }
......
This diff is collapsed.
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
static DEFINE_MUTEX(bat_lock); /* protects gpio pins */ static DEFINE_MUTEX(bat_lock); /* protects gpio pins */
static struct work_struct bat_work; static struct work_struct bat_work;
static struct ucb1x00 *ucb; static struct ucb1x00 *ucb;
static int wakeup_enabled;
struct collie_bat { struct collie_bat {
int status; int status;
...@@ -291,11 +292,21 @@ static int collie_bat_suspend(struct ucb1x00_dev *dev) ...@@ -291,11 +292,21 @@ static int collie_bat_suspend(struct ucb1x00_dev *dev)
{ {
/* flush all pending status updates */ /* flush all pending status updates */
flush_work(&bat_work); flush_work(&bat_work);
if (device_may_wakeup(&dev->ucb->dev) &&
collie_bat_main.status == POWER_SUPPLY_STATUS_CHARGING)
wakeup_enabled = !enable_irq_wake(gpio_to_irq(COLLIE_GPIO_CO));
else
wakeup_enabled = 0;
return 0; return 0;
} }
static int collie_bat_resume(struct ucb1x00_dev *dev) static int collie_bat_resume(struct ucb1x00_dev *dev)
{ {
if (wakeup_enabled)
disable_irq_wake(gpio_to_irq(COLLIE_GPIO_CO));
/* things may have changed while we were away */ /* things may have changed while we were away */
schedule_work(&bat_work); schedule_work(&bat_work);
return 0; return 0;
...@@ -334,10 +345,15 @@ static int collie_bat_probe(struct ucb1x00_dev *dev) ...@@ -334,10 +345,15 @@ static int collie_bat_probe(struct ucb1x00_dev *dev)
collie_bat_gpio_isr, collie_bat_gpio_isr,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
"main full", &collie_bat_main); "main full", &collie_bat_main);
if (!ret) { if (ret)
goto err_irq;
device_init_wakeup(&ucb->dev, 1);
schedule_work(&bat_work); schedule_work(&bat_work);
return 0; return 0;
}
err_irq:
power_supply_unregister(&collie_bat_bu.psy); power_supply_unregister(&collie_bat_bu.psy);
err_psy_reg_bu: err_psy_reg_bu:
power_supply_unregister(&collie_bat_main.psy); power_supply_unregister(&collie_bat_main.psy);
......
...@@ -229,7 +229,7 @@ static int gpio_charger_suspend(struct device *dev) ...@@ -229,7 +229,7 @@ static int gpio_charger_suspend(struct device *dev)
if (device_may_wakeup(dev)) if (device_may_wakeup(dev))
gpio_charger->wakeup_enabled = gpio_charger->wakeup_enabled =
enable_irq_wake(gpio_charger->irq); !enable_irq_wake(gpio_charger->irq);
return 0; return 0;
} }
...@@ -239,7 +239,7 @@ static int gpio_charger_resume(struct device *dev) ...@@ -239,7 +239,7 @@ static int gpio_charger_resume(struct device *dev)
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct gpio_charger *gpio_charger = platform_get_drvdata(pdev); struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
if (gpio_charger->wakeup_enabled) if (device_may_wakeup(dev) && gpio_charger->wakeup_enabled)
disable_irq_wake(gpio_charger->irq); disable_irq_wake(gpio_charger->irq);
power_supply_changed(&gpio_charger->charger); power_supply_changed(&gpio_charger->charger);
......
This diff is collapsed.
...@@ -658,7 +658,7 @@ max17042_get_pdata(struct device *dev) ...@@ -658,7 +658,7 @@ max17042_get_pdata(struct device *dev)
} }
#endif #endif
static struct regmap_config max17042_regmap_config = { static const struct regmap_config max17042_regmap_config = {
.reg_bits = 8, .reg_bits = 8,
.val_bits = 16, .val_bits = 16,
.val_format_endian = REGMAP_ENDIAN_NATIVE, .val_format_endian = REGMAP_ENDIAN_NATIVE,
......
This diff is collapsed.
...@@ -39,14 +39,13 @@ config POWER_RESET_AXXIA ...@@ -39,14 +39,13 @@ config POWER_RESET_AXXIA
Say Y if you have an Axxia family SoC. Say Y if you have an Axxia family SoC.
config POWER_RESET_BRCMSTB config POWER_RESET_BRCMSTB
bool "Broadcom STB reset driver" if COMPILE_TEST bool "Broadcom STB reset driver"
depends on ARM depends on ARM || MIPS || COMPILE_TEST
default ARCH_BRCMSTB default ARCH_BRCMSTB
help help
This driver provides restart support for ARM-based Broadcom STB This driver provides restart support for Broadcom STB boards.
boards.
Say Y here if you have an ARM-based Broadcom STB board and you wish Say Y here if you have a Broadcom STB board and you wish
to have restart support. to have restart support.
config POWER_RESET_GPIO config POWER_RESET_GPIO
...@@ -104,23 +103,16 @@ config POWER_RESET_QNAP ...@@ -104,23 +103,16 @@ config POWER_RESET_QNAP
config POWER_RESET_RESTART config POWER_RESET_RESTART
bool "Restart power-off driver" bool "Restart power-off driver"
depends on ARM
help help
Some boards don't actually have the ability to power off. Some boards don't actually have the ability to power off.
Instead they restart, and u-boot holds the SoC until the Instead they restart, and u-boot holds the SoC until the
user presses a key. u-boot then boots into Linux. user presses a key. u-boot then boots into Linux.
config POWER_RESET_SUN6I
bool "Allwinner A31 SoC reset driver"
depends on ARCH_SUNXI
help
Reboot support for the Allwinner A31 SoCs.
config POWER_RESET_ST config POWER_RESET_ST
bool "ST restart power-off driver" bool "ST restart driver"
depends on ARCH_STI depends on ARCH_STI
help help
Power off and reset support for STMicroelectronics boards. Reset support for STMicroelectronics boards.
config POWER_RESET_VERSATILE config POWER_RESET_VERSATILE
bool "ARM Versatile family reboot driver" bool "ARM Versatile family reboot driver"
...@@ -159,5 +151,11 @@ config POWER_RESET_SYSCON ...@@ -159,5 +151,11 @@ config POWER_RESET_SYSCON
help help
Reboot support for generic SYSCON mapped register reset. Reboot support for generic SYSCON mapped register reset.
config POWER_RESET_RMOBILE
tristate "Renesas R-Mobile reset driver"
depends on ARCH_RMOBILE || COMPILE_TEST
help
Reboot support for Renesas R-Mobile and SH-Mobile SoCs.
endif endif
...@@ -11,10 +11,10 @@ obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o ...@@ -11,10 +11,10 @@ obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o
obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
obj-$(CONFIG_POWER_RESET_SUN6I) += sun6i-reboot.o
obj-$(CONFIG_POWER_RESET_ST) += st-poweroff.o obj-$(CONFIG_POWER_RESET_ST) += st-poweroff.o
obj-$(CONFIG_POWER_RESET_VERSATILE) += arm-versatile-reboot.o obj-$(CONFIG_POWER_RESET_VERSATILE) += arm-versatile-reboot.o
obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o
obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o
obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o
obj-$(CONFIG_POWER_RESET_SYSCON) += syscon-reboot.o obj-$(CONFIG_POWER_RESET_SYSCON) += syscon-reboot.o
obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o
...@@ -13,16 +13,22 @@ ...@@ -13,16 +13,22 @@
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/of.h> #include <linux/of.h>
#include <asm/system_misc.h>
#define INTEGRATOR_HDR_CTRL_OFFSET 0x0C
#define INTEGRATOR_HDR_LOCK_OFFSET 0x14
#define INTEGRATOR_CM_CTRL_RESET (1 << 3)
#define REALVIEW_SYS_LOCK_OFFSET 0x20 #define REALVIEW_SYS_LOCK_OFFSET 0x20
#define REALVIEW_SYS_LOCK_VAL 0xA05F
#define REALVIEW_SYS_RESETCTL_OFFSET 0x40 #define REALVIEW_SYS_RESETCTL_OFFSET 0x40
/* Magic unlocking token used on all Versatile boards */
#define VERSATILE_LOCK_VAL 0xA05F
/* /*
* We detect the different syscon types from the compatible strings. * We detect the different syscon types from the compatible strings.
*/ */
enum versatile_reboot { enum versatile_reboot {
INTEGRATOR_REBOOT_CM,
REALVIEW_REBOOT_EB, REALVIEW_REBOOT_EB,
REALVIEW_REBOOT_PB1176, REALVIEW_REBOOT_PB1176,
REALVIEW_REBOOT_PB11MP, REALVIEW_REBOOT_PB11MP,
...@@ -35,6 +41,10 @@ static struct regmap *syscon_regmap; ...@@ -35,6 +41,10 @@ static struct regmap *syscon_regmap;
static enum versatile_reboot versatile_reboot_type; static enum versatile_reboot versatile_reboot_type;
static const struct of_device_id versatile_reboot_of_match[] = { static const struct of_device_id versatile_reboot_of_match[] = {
{
.compatible = "arm,core-module-integrator",
.data = (void *)INTEGRATOR_REBOOT_CM
},
{ {
.compatible = "arm,realview-eb-syscon", .compatible = "arm,realview-eb-syscon",
.data = (void *)REALVIEW_REBOOT_EB, .data = (void *)REALVIEW_REBOOT_EB,
...@@ -55,31 +65,47 @@ static const struct of_device_id versatile_reboot_of_match[] = { ...@@ -55,31 +65,47 @@ static const struct of_device_id versatile_reboot_of_match[] = {
.compatible = "arm,realview-pbx-syscon", .compatible = "arm,realview-pbx-syscon",
.data = (void *)REALVIEW_REBOOT_PBX, .data = (void *)REALVIEW_REBOOT_PBX,
}, },
{},
}; };
static void versatile_reboot(enum reboot_mode mode, const char *cmd) static int versatile_reboot(struct notifier_block *this, unsigned long mode,
void *cmd)
{ {
/* Unlock the reset register */ /* Unlock the reset register */
regmap_write(syscon_regmap, REALVIEW_SYS_LOCK_OFFSET,
REALVIEW_SYS_LOCK_VAL);
/* Then hit reset on the different machines */ /* Then hit reset on the different machines */
switch (versatile_reboot_type) { switch (versatile_reboot_type) {
case INTEGRATOR_REBOOT_CM:
regmap_write(syscon_regmap, INTEGRATOR_HDR_LOCK_OFFSET,
VERSATILE_LOCK_VAL);
regmap_update_bits(syscon_regmap,
INTEGRATOR_HDR_CTRL_OFFSET,
INTEGRATOR_CM_CTRL_RESET,
INTEGRATOR_CM_CTRL_RESET);
break;
case REALVIEW_REBOOT_EB: case REALVIEW_REBOOT_EB:
regmap_write(syscon_regmap, REALVIEW_SYS_LOCK_OFFSET,
VERSATILE_LOCK_VAL);
regmap_write(syscon_regmap, regmap_write(syscon_regmap,
REALVIEW_SYS_RESETCTL_OFFSET, 0x0008); REALVIEW_SYS_RESETCTL_OFFSET, 0x0008);
break; break;
case REALVIEW_REBOOT_PB1176: case REALVIEW_REBOOT_PB1176:
regmap_write(syscon_regmap, REALVIEW_SYS_LOCK_OFFSET,
VERSATILE_LOCK_VAL);
regmap_write(syscon_regmap, regmap_write(syscon_regmap,
REALVIEW_SYS_RESETCTL_OFFSET, 0x0100); REALVIEW_SYS_RESETCTL_OFFSET, 0x0100);
break; break;
case REALVIEW_REBOOT_PB11MP: case REALVIEW_REBOOT_PB11MP:
case REALVIEW_REBOOT_PBA8: case REALVIEW_REBOOT_PBA8:
regmap_write(syscon_regmap, REALVIEW_SYS_LOCK_OFFSET,
VERSATILE_LOCK_VAL);
regmap_write(syscon_regmap, REALVIEW_SYS_RESETCTL_OFFSET, regmap_write(syscon_regmap, REALVIEW_SYS_RESETCTL_OFFSET,
0x0000); 0x0000);
regmap_write(syscon_regmap, REALVIEW_SYS_RESETCTL_OFFSET, regmap_write(syscon_regmap, REALVIEW_SYS_RESETCTL_OFFSET,
0x0004); 0x0004);
break; break;
case REALVIEW_REBOOT_PBX: case REALVIEW_REBOOT_PBX:
regmap_write(syscon_regmap, REALVIEW_SYS_LOCK_OFFSET,
VERSATILE_LOCK_VAL);
regmap_write(syscon_regmap, REALVIEW_SYS_RESETCTL_OFFSET, regmap_write(syscon_regmap, REALVIEW_SYS_RESETCTL_OFFSET,
0x00f0); 0x00f0);
regmap_write(syscon_regmap, REALVIEW_SYS_RESETCTL_OFFSET, regmap_write(syscon_regmap, REALVIEW_SYS_RESETCTL_OFFSET,
...@@ -87,12 +113,20 @@ static void versatile_reboot(enum reboot_mode mode, const char *cmd) ...@@ -87,12 +113,20 @@ static void versatile_reboot(enum reboot_mode mode, const char *cmd)
break; break;
} }
dsb(); dsb();
return NOTIFY_DONE;
} }
static struct notifier_block versatile_reboot_nb = {
.notifier_call = versatile_reboot,
.priority = 192,
};
static int __init versatile_reboot_probe(void) static int __init versatile_reboot_probe(void)
{ {
const struct of_device_id *reboot_id; const struct of_device_id *reboot_id;
struct device_node *np; struct device_node *np;
int err;
np = of_find_matching_node_and_match(NULL, versatile_reboot_of_match, np = of_find_matching_node_and_match(NULL, versatile_reboot_of_match,
&reboot_id); &reboot_id);
...@@ -104,7 +138,10 @@ static int __init versatile_reboot_probe(void) ...@@ -104,7 +138,10 @@ static int __init versatile_reboot_probe(void)
if (IS_ERR(syscon_regmap)) if (IS_ERR(syscon_regmap))
return PTR_ERR(syscon_regmap); return PTR_ERR(syscon_regmap);
arm_pm_restart = versatile_reboot; err = register_restart_handler(&versatile_reboot_nb);
if (err)
return err;
pr_info("versatile reboot driver registered\n"); pr_info("versatile reboot driver registered\n");
return 0; return 0;
} }
......
...@@ -71,10 +71,11 @@ static void at91_poweroff(void) ...@@ -71,10 +71,11 @@ static void at91_poweroff(void)
writel(AT91_SHDW_KEY | AT91_SHDW_SHDW, at91_shdwc_base + AT91_SHDW_CR); writel(AT91_SHDW_KEY | AT91_SHDW_SHDW, at91_shdwc_base + AT91_SHDW_CR);
} }
const enum wakeup_type at91_poweroff_get_wakeup_mode(struct device_node *np) static int at91_poweroff_get_wakeup_mode(struct device_node *np)
{ {
const char *pm; const char *pm;
int err, i; unsigned int i;
int err;
err = of_property_read_string(np, "atmel,wakeup-mode", &pm); err = of_property_read_string(np, "atmel,wakeup-mode", &pm);
if (err < 0) if (err < 0)
...@@ -90,7 +91,7 @@ const enum wakeup_type at91_poweroff_get_wakeup_mode(struct device_node *np) ...@@ -90,7 +91,7 @@ const enum wakeup_type at91_poweroff_get_wakeup_mode(struct device_node *np)
static void at91_poweroff_dt_set_wakeup_mode(struct platform_device *pdev) static void at91_poweroff_dt_set_wakeup_mode(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
enum wakeup_type wakeup_mode; int wakeup_mode;
u32 mode = 0, tmp; u32 mode = 0, tmp;
wakeup_mode = at91_poweroff_get_wakeup_mode(np); wakeup_mode = at91_poweroff_get_wakeup_mode(np);
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <asm/system_misc.h>
#include <soc/at91/at91sam9_ddrsdr.h> #include <soc/at91/at91sam9_ddrsdr.h>
#include <soc/at91/at91sam9_sdramc.h> #include <soc/at91/at91sam9_sdramc.h>
...@@ -54,7 +52,8 @@ static void __iomem *at91_ramc_base[2], *at91_rstc_base; ...@@ -54,7 +52,8 @@ static void __iomem *at91_ramc_base[2], *at91_rstc_base;
* reset register it can be left driving the data bus and * reset register it can be left driving the data bus and
* killing the chance of a subsequent boot from NAND * killing the chance of a subsequent boot from NAND
*/ */
static void at91sam9260_restart(enum reboot_mode mode, const char *cmd) static int at91sam9260_restart(struct notifier_block *this, unsigned long mode,
void *cmd)
{ {
asm volatile( asm volatile(
/* Align to cache lines */ /* Align to cache lines */
...@@ -76,9 +75,12 @@ static void at91sam9260_restart(enum reboot_mode mode, const char *cmd) ...@@ -76,9 +75,12 @@ static void at91sam9260_restart(enum reboot_mode mode, const char *cmd)
"r" (1), "r" (1),
"r" (AT91_SDRAMC_LPCB_POWER_DOWN), "r" (AT91_SDRAMC_LPCB_POWER_DOWN),
"r" (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST)); "r" (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST));
return NOTIFY_DONE;
} }
static void at91sam9g45_restart(enum reboot_mode mode, const char *cmd) static int at91sam9g45_restart(struct notifier_block *this, unsigned long mode,
void *cmd)
{ {
asm volatile( asm volatile(
/* /*
...@@ -117,6 +119,8 @@ static void at91sam9g45_restart(enum reboot_mode mode, const char *cmd) ...@@ -117,6 +119,8 @@ static void at91sam9g45_restart(enum reboot_mode mode, const char *cmd)
"r" (AT91_DDRSDRC_LPCB_POWER_DOWN), "r" (AT91_DDRSDRC_LPCB_POWER_DOWN),
"r" (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST) "r" (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST)
: "r0"); : "r0");
return NOTIFY_DONE;
} }
static void __init at91_reset_status(struct platform_device *pdev) static void __init at91_reset_status(struct platform_device *pdev)
...@@ -161,6 +165,10 @@ static struct of_device_id at91_reset_of_match[] = { ...@@ -161,6 +165,10 @@ static struct of_device_id at91_reset_of_match[] = {
{ /* sentinel */ } { /* sentinel */ }
}; };
static struct notifier_block at91_restart_nb = {
.priority = 192,
};
static int at91_reset_of_probe(struct platform_device *pdev) static int at91_reset_of_probe(struct platform_device *pdev)
{ {
const struct of_device_id *match; const struct of_device_id *match;
...@@ -183,9 +191,8 @@ static int at91_reset_of_probe(struct platform_device *pdev) ...@@ -183,9 +191,8 @@ static int at91_reset_of_probe(struct platform_device *pdev)
} }
match = of_match_node(at91_reset_of_match, pdev->dev.of_node); match = of_match_node(at91_reset_of_match, pdev->dev.of_node);
arm_pm_restart = match->data; at91_restart_nb.notifier_call = match->data;
return register_restart_handler(&at91_restart_nb);
return 0;
} }
static int at91_reset_platform_probe(struct platform_device *pdev) static int at91_reset_platform_probe(struct platform_device *pdev)
...@@ -212,10 +219,11 @@ static int at91_reset_platform_probe(struct platform_device *pdev) ...@@ -212,10 +219,11 @@ static int at91_reset_platform_probe(struct platform_device *pdev)
} }
match = platform_get_device_id(pdev); match = platform_get_device_id(pdev);
arm_pm_restart = (void (*)(enum reboot_mode, const char*)) at91_restart_nb.notifier_call =
match->driver_data; (int (*)(struct notifier_block *,
unsigned long, void *)) match->driver_data;
return 0; return register_restart_handler(&at91_restart_nb);
} }
static int at91_reset_probe(struct platform_device *pdev) static int at91_reset_probe(struct platform_device *pdev)
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/bitops.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -34,13 +35,20 @@ static struct regmap *regmap; ...@@ -34,13 +35,20 @@ static struct regmap *regmap;
static u32 rst_src_en; static u32 rst_src_en;
static u32 sw_mstr_rst; static u32 sw_mstr_rst;
struct reset_reg_mask {
u32 rst_src_en_mask;
u32 sw_mstr_rst_mask;
};
static const struct reset_reg_mask *reset_masks;
static int brcmstb_restart_handler(struct notifier_block *this, static int brcmstb_restart_handler(struct notifier_block *this,
unsigned long mode, void *cmd) unsigned long mode, void *cmd)
{ {
int rc; int rc;
u32 tmp; u32 tmp;
rc = regmap_write(regmap, rst_src_en, 1); rc = regmap_write(regmap, rst_src_en, reset_masks->rst_src_en_mask);
if (rc) { if (rc) {
pr_err("failed to write rst_src_en (%d)\n", rc); pr_err("failed to write rst_src_en (%d)\n", rc);
return NOTIFY_DONE; return NOTIFY_DONE;
...@@ -52,7 +60,7 @@ static int brcmstb_restart_handler(struct notifier_block *this, ...@@ -52,7 +60,7 @@ static int brcmstb_restart_handler(struct notifier_block *this,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
rc = regmap_write(regmap, sw_mstr_rst, 1); rc = regmap_write(regmap, sw_mstr_rst, reset_masks->sw_mstr_rst_mask);
if (rc) { if (rc) {
pr_err("failed to write sw_mstr_rst (%d)\n", rc); pr_err("failed to write sw_mstr_rst (%d)\n", rc);
return NOTIFY_DONE; return NOTIFY_DONE;
...@@ -75,10 +83,34 @@ static struct notifier_block brcmstb_restart_nb = { ...@@ -75,10 +83,34 @@ static struct notifier_block brcmstb_restart_nb = {
.priority = 128, .priority = 128,
}; };
static const struct reset_reg_mask reset_bits_40nm = {
.rst_src_en_mask = BIT(0),
.sw_mstr_rst_mask = BIT(0),
};
static const struct reset_reg_mask reset_bits_65nm = {
.rst_src_en_mask = BIT(3),
.sw_mstr_rst_mask = BIT(31),
};
static const struct of_device_id of_match[] = {
{ .compatible = "brcm,brcmstb-reboot", .data = &reset_bits_40nm },
{ .compatible = "brcm,bcm7038-reboot", .data = &reset_bits_65nm },
{},
};
static int brcmstb_reboot_probe(struct platform_device *pdev) static int brcmstb_reboot_probe(struct platform_device *pdev)
{ {
int rc; int rc;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
const struct of_device_id *of_id;
of_id = of_match_node(of_match, np);
if (!of_id) {
pr_err("failed to look up compatible string\n");
return -EINVAL;
}
reset_masks = of_id->data;
regmap = syscon_regmap_lookup_by_phandle(np, "syscon"); regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
...@@ -108,11 +140,6 @@ static int brcmstb_reboot_probe(struct platform_device *pdev) ...@@ -108,11 +140,6 @@ static int brcmstb_reboot_probe(struct platform_device *pdev)
return rc; return rc;
} }
static const struct of_device_id of_match[] = {
{ .compatible = "brcm,brcmstb-reboot", },
{},
};
static struct platform_driver brcmstb_reboot_driver = { static struct platform_driver brcmstb_reboot_driver = {
.probe = brcmstb_reboot_probe, .probe = brcmstb_reboot_probe,
.driver = { .driver = {
......
This diff is collapsed.
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <asm/system_misc.h>
static void restart_poweroff_do_poweroff(void) static void restart_poweroff_do_poweroff(void)
{ {
......
/*
* Renesas R-Mobile Reset Driver
*
* Copyright (C) 2014 Glider bvba
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
#include <linux/io.h>
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/printk.h>
#include <linux/reboot.h>
/* SYSC Register Bank 2 */
#define RESCNT2 0x20 /* Reset Control Register 2 */
/* Reset Control Register 2 */
#define RESCNT2_PRES 0x80000000 /* Soft power-on reset */
static void __iomem *sysc_base2;
static int rmobile_reset_handler(struct notifier_block *this,
unsigned long mode, void *cmd)
{
pr_debug("%s %lu\n", __func__, mode);
/* Let's assume we have acquired the HPB semaphore */
writel(RESCNT2_PRES, sysc_base2 + RESCNT2);
return NOTIFY_DONE;
}
static struct notifier_block rmobile_reset_nb = {
.notifier_call = rmobile_reset_handler,
.priority = 192,
};
static int rmobile_reset_probe(struct platform_device *pdev)
{
int error;
sysc_base2 = of_iomap(pdev->dev.of_node, 1);
if (!sysc_base2)
return -ENODEV;
error = register_restart_handler(&rmobile_reset_nb);
if (error) {
dev_err(&pdev->dev,
"cannot register restart handler (err=%d)\n", error);
goto fail_unmap;
}
return 0;
fail_unmap:
iounmap(sysc_base2);
return error;
}
static int rmobile_reset_remove(struct platform_device *pdev)
{
unregister_restart_handler(&rmobile_reset_nb);
iounmap(sysc_base2);
return 0;
}
static const struct of_device_id rmobile_reset_of_match[] = {
{ .compatible = "renesas,sysc-rmobile", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, rmobile_reset_of_match);
static struct platform_driver rmobile_reset_driver = {
.probe = rmobile_reset_probe,
.remove = rmobile_reset_remove,
.driver = {
.name = "rmobile_reset",
.of_match_table = rmobile_reset_of_match,
},
};
module_platform_driver(rmobile_reset_driver);
MODULE_DESCRIPTION("Renesas R-Mobile Reset Driver");
MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
MODULE_LICENSE("GPL v2");
...@@ -15,10 +15,9 @@ ...@@ -15,10 +15,9 @@
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
#include <linux/reboot.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <asm/system_misc.h>
struct reset_syscfg { struct reset_syscfg {
struct regmap *regmap; struct regmap *regmap;
/* syscfg used for reset */ /* syscfg used for reset */
...@@ -75,7 +74,8 @@ static struct reset_syscfg stid127_reset = { ...@@ -75,7 +74,8 @@ static struct reset_syscfg stid127_reset = {
static struct reset_syscfg *st_restart_syscfg; static struct reset_syscfg *st_restart_syscfg;
static void st_restart(enum reboot_mode reboot_mode, const char *cmd) static int st_restart(struct notifier_block *this, unsigned long mode,
void *cmd)
{ {
/* reset syscfg updated */ /* reset syscfg updated */
regmap_update_bits(st_restart_syscfg->regmap, regmap_update_bits(st_restart_syscfg->regmap,
...@@ -88,8 +88,15 @@ static void st_restart(enum reboot_mode reboot_mode, const char *cmd) ...@@ -88,8 +88,15 @@ static void st_restart(enum reboot_mode reboot_mode, const char *cmd)
st_restart_syscfg->offset_rst_msk, st_restart_syscfg->offset_rst_msk,
st_restart_syscfg->mask_rst_msk, st_restart_syscfg->mask_rst_msk,
0); 0);
return NOTIFY_DONE;
} }
static struct notifier_block st_restart_nb = {
.notifier_call = st_restart,
.priority = 192,
};
static struct of_device_id st_reset_of_match[] = { static struct of_device_id st_reset_of_match[] = {
{ {
.compatible = "st,stih415-restart", .compatible = "st,stih415-restart",
...@@ -126,9 +133,7 @@ static int st_reset_probe(struct platform_device *pdev) ...@@ -126,9 +133,7 @@ static int st_reset_probe(struct platform_device *pdev)
return PTR_ERR(st_restart_syscfg->regmap); return PTR_ERR(st_restart_syscfg->regmap);
} }
arm_pm_restart = st_restart; return register_restart_handler(&st_restart_nb);
return 0;
} }
static struct platform_driver st_reset_driver = { static struct platform_driver st_reset_driver = {
......
/*
* Allwinner A31 SoCs reset code
*
* Copyright (C) 2012-2014 Maxime Ripard
*
* Maxime Ripard <maxime.ripard@free-electrons.com>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/reboot.h>
#include <asm/system_misc.h>
#define SUN6I_WATCHDOG1_IRQ_REG 0x00
#define SUN6I_WATCHDOG1_CTRL_REG 0x10
#define SUN6I_WATCHDOG1_CTRL_RESTART BIT(0)
#define SUN6I_WATCHDOG1_CONFIG_REG 0x14
#define SUN6I_WATCHDOG1_CONFIG_RESTART BIT(0)
#define SUN6I_WATCHDOG1_CONFIG_IRQ BIT(1)
#define SUN6I_WATCHDOG1_MODE_REG 0x18
#define SUN6I_WATCHDOG1_MODE_ENABLE BIT(0)
static void __iomem *wdt_base;
static void sun6i_wdt_restart(enum reboot_mode mode, const char *cmd)
{
if (!wdt_base)
return;
/* Disable interrupts */
writel(0, wdt_base + SUN6I_WATCHDOG1_IRQ_REG);
/* We want to disable the IRQ and just reset the whole system */
writel(SUN6I_WATCHDOG1_CONFIG_RESTART,
wdt_base + SUN6I_WATCHDOG1_CONFIG_REG);
/* Enable timer. The default and lowest interval value is 0.5s */
writel(SUN6I_WATCHDOG1_MODE_ENABLE,
wdt_base + SUN6I_WATCHDOG1_MODE_REG);
/* Restart the watchdog. */
writel(SUN6I_WATCHDOG1_CTRL_RESTART,
wdt_base + SUN6I_WATCHDOG1_CTRL_REG);
while (1) {
mdelay(5);
writel(SUN6I_WATCHDOG1_MODE_ENABLE,
wdt_base + SUN6I_WATCHDOG1_MODE_REG);
}
}
static int sun6i_reboot_probe(struct platform_device *pdev)
{
wdt_base = of_iomap(pdev->dev.of_node, 0);
if (!wdt_base) {
WARN(1, "failed to map watchdog base address");
return -ENODEV;
}
arm_pm_restart = sun6i_wdt_restart;
return 0;
}
static struct of_device_id sun6i_reboot_of_match[] = {
{ .compatible = "allwinner,sun6i-a31-wdt" },
{}
};
static struct platform_driver sun6i_reboot_driver = {
.probe = sun6i_reboot_probe,
.driver = {
.name = "sun6i-reboot",
.of_match_table = sun6i_reboot_of_match,
},
};
module_platform_driver(sun6i_reboot_driver);
...@@ -111,23 +111,20 @@ static int _vexpress_register_restart_handler(struct device *dev) ...@@ -111,23 +111,20 @@ static int _vexpress_register_restart_handler(struct device *dev)
static int vexpress_reset_probe(struct platform_device *pdev) static int vexpress_reset_probe(struct platform_device *pdev)
{ {
enum vexpress_reset_func func;
const struct of_device_id *match = const struct of_device_id *match =
of_match_device(vexpress_reset_of_match, &pdev->dev); of_match_device(vexpress_reset_of_match, &pdev->dev);
struct regmap *regmap; struct regmap *regmap;
int ret = 0; int ret = 0;
if (match) if (!match)
func = (enum vexpress_reset_func)match->data; return -EINVAL;
else
func = pdev->id_entry->driver_data;
regmap = devm_regmap_init_vexpress_config(&pdev->dev); regmap = devm_regmap_init_vexpress_config(&pdev->dev);
if (IS_ERR(regmap)) if (IS_ERR(regmap))
return PTR_ERR(regmap); return PTR_ERR(regmap);
dev_set_drvdata(&pdev->dev, regmap); dev_set_drvdata(&pdev->dev, regmap);
switch (func) { switch ((enum vexpress_reset_func)match->data) {
case FUNC_SHUTDOWN: case FUNC_SHUTDOWN:
vexpress_power_off_device = &pdev->dev; vexpress_power_off_device = &pdev->dev;
pm_power_off = vexpress_power_off; pm_power_off = vexpress_power_off;
...@@ -144,20 +141,12 @@ static int vexpress_reset_probe(struct platform_device *pdev) ...@@ -144,20 +141,12 @@ static int vexpress_reset_probe(struct platform_device *pdev)
return ret; return ret;
} }
static const struct platform_device_id vexpress_reset_id_table[] = {
{ .name = "vexpress-reset", .driver_data = FUNC_RESET, },
{ .name = "vexpress-shutdown", .driver_data = FUNC_SHUTDOWN, },
{ .name = "vexpress-reboot", .driver_data = FUNC_REBOOT, },
{}
};
static struct platform_driver vexpress_reset_driver = { static struct platform_driver vexpress_reset_driver = {
.probe = vexpress_reset_probe, .probe = vexpress_reset_probe,
.driver = { .driver = {
.name = "vexpress-reset", .name = "vexpress-reset",
.of_match_table = vexpress_reset_of_match, .of_match_table = vexpress_reset_of_match,
}, },
.id_table = vexpress_reset_id_table,
}; };
static int __init vexpress_reset_init(void) static int __init vexpress_reset_init(void)
......
/*
* Fuel gauge driver for Richtek RT5033
*
* Copyright (C) 2014 Samsung Electronics, Co., Ltd.
* Author: Beomho Seo <beomho.seo@samsung.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published bythe Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/mfd/rt5033-private.h>
#include <linux/mfd/rt5033.h>
static int rt5033_battery_get_capacity(struct i2c_client *client)
{
struct rt5033_battery *battery = i2c_get_clientdata(client);
u32 msb;
regmap_read(battery->regmap, RT5033_FUEL_REG_SOC_H, &msb);
return msb;
}
static int rt5033_battery_get_present(struct i2c_client *client)
{
struct rt5033_battery *battery = i2c_get_clientdata(client);
u32 val;
regmap_read(battery->regmap, RT5033_FUEL_REG_CONFIG_L, &val);
return (val & RT5033_FUEL_BAT_PRESENT) ? true : false;
}
static int rt5033_battery_get_watt_prop(struct i2c_client *client,
enum power_supply_property psp)
{
struct rt5033_battery *battery = i2c_get_clientdata(client);
unsigned int regh, regl;
int ret;
u32 msb, lsb;
switch (psp) {
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
regh = RT5033_FUEL_REG_VBAT_H;
regl = RT5033_FUEL_REG_VBAT_L;
break;
case POWER_SUPPLY_PROP_VOLTAGE_AVG:
regh = RT5033_FUEL_REG_AVG_VOLT_H;
regl = RT5033_FUEL_REG_AVG_VOLT_L;
break;
case POWER_SUPPLY_PROP_VOLTAGE_OCV:
regh = RT5033_FUEL_REG_OCV_H;
regl = RT5033_FUEL_REG_OCV_L;
break;
default:
return -EINVAL;
}
regmap_read(battery->regmap, regh, &msb);
regmap_read(battery->regmap, regl, &lsb);
ret = ((msb << 4) + (lsb >> 4)) * 1250 / 1000;
return ret;
}
static int rt5033_battery_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct rt5033_battery *battery = container_of(psy,
struct rt5033_battery, psy);
switch (psp) {
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
case POWER_SUPPLY_PROP_VOLTAGE_AVG:
case POWER_SUPPLY_PROP_VOLTAGE_OCV:
val->intval = rt5033_battery_get_watt_prop(battery->client,
psp);
break;
case POWER_SUPPLY_PROP_PRESENT:
val->intval = rt5033_battery_get_present(battery->client);
break;
case POWER_SUPPLY_PROP_CAPACITY:
val->intval = rt5033_battery_get_capacity(battery->client);
break;
default:
return -EINVAL;
}
return 0;
}
static enum power_supply_property rt5033_battery_props[] = {
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_VOLTAGE_AVG,
POWER_SUPPLY_PROP_VOLTAGE_OCV,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_CAPACITY,
};
static struct regmap_config rt5033_battery_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = RT5033_FUEL_REG_END,
};
static int rt5033_battery_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
struct rt5033_battery *battery;
u32 ret;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
return -EIO;
battery = devm_kzalloc(&client->dev, sizeof(*battery), GFP_KERNEL);
if (!battery)
return -EINVAL;
battery->client = client;
battery->regmap = devm_regmap_init_i2c(client,
&rt5033_battery_regmap_config);
if (IS_ERR(battery->regmap)) {
dev_err(&client->dev, "Failed to initialize regmap\n");
return -EINVAL;
}
i2c_set_clientdata(client, battery);
battery->psy.name = "rt5033-battery";
battery->psy.type = POWER_SUPPLY_TYPE_BATTERY;
battery->psy.get_property = rt5033_battery_get_property;
battery->psy.properties = rt5033_battery_props;
battery->psy.num_properties = ARRAY_SIZE(rt5033_battery_props);
ret = power_supply_register(&client->dev, &battery->psy);
if (ret) {
dev_err(&client->dev, "Failed to register power supply\n");
return ret;
}
return 0;
}
static int rt5033_battery_remove(struct i2c_client *client)
{
struct rt5033_battery *battery = i2c_get_clientdata(client);
power_supply_unregister(&battery->psy);
return 0;
}
static const struct i2c_device_id rt5033_battery_id[] = {
{ "rt5033-battery", },
{ }
};
MODULE_DEVICE_TABLE(platform, rt5033_battery_id);
static struct i2c_driver rt5033_battery_driver = {
.driver = {
.name = "rt5033-battery",
},
.probe = rt5033_battery_probe,
.remove = rt5033_battery_remove,
.id_table = rt5033_battery_id,
};
module_i2c_driver(rt5033_battery_driver);
MODULE_DESCRIPTION("Richtek RT5033 fuel gauge driver");
MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>");
MODULE_LICENSE("GPL");
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/vermagic.h> #include <linux/vermagic.h>
enum test_power_id {
TEST_AC,
TEST_BATTERY,
TEST_USB,
TEST_POWER_NUM,
};
static int ac_online = 1; static int ac_online = 1;
static int usb_online = 1; static int usb_online = 1;
static int battery_status = POWER_SUPPLY_STATUS_DISCHARGING; static int battery_status = POWER_SUPPLY_STATUS_DISCHARGING;
...@@ -147,7 +154,7 @@ static char *test_power_ac_supplied_to[] = { ...@@ -147,7 +154,7 @@ static char *test_power_ac_supplied_to[] = {
}; };
static struct power_supply test_power_supplies[] = { static struct power_supply test_power_supplies[] = {
{ [TEST_AC] = {
.name = "test_ac", .name = "test_ac",
.type = POWER_SUPPLY_TYPE_MAINS, .type = POWER_SUPPLY_TYPE_MAINS,
.supplied_to = test_power_ac_supplied_to, .supplied_to = test_power_ac_supplied_to,
...@@ -155,13 +162,15 @@ static struct power_supply test_power_supplies[] = { ...@@ -155,13 +162,15 @@ static struct power_supply test_power_supplies[] = {
.properties = test_power_ac_props, .properties = test_power_ac_props,
.num_properties = ARRAY_SIZE(test_power_ac_props), .num_properties = ARRAY_SIZE(test_power_ac_props),
.get_property = test_power_get_ac_property, .get_property = test_power_get_ac_property,
}, { },
[TEST_BATTERY] = {
.name = "test_battery", .name = "test_battery",
.type = POWER_SUPPLY_TYPE_BATTERY, .type = POWER_SUPPLY_TYPE_BATTERY,
.properties = test_power_battery_props, .properties = test_power_battery_props,
.num_properties = ARRAY_SIZE(test_power_battery_props), .num_properties = ARRAY_SIZE(test_power_battery_props),
.get_property = test_power_get_battery_property, .get_property = test_power_get_battery_property,
}, { },
[TEST_USB] = {
.name = "test_usb", .name = "test_usb",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.supplied_to = test_power_ac_supplied_to, .supplied_to = test_power_ac_supplied_to,
...@@ -178,6 +187,8 @@ static int __init test_power_init(void) ...@@ -178,6 +187,8 @@ static int __init test_power_init(void)
int i; int i;
int ret; int ret;
BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_supplies));
for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) { for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) {
ret = power_supply_register(NULL, &test_power_supplies[i]); ret = power_supply_register(NULL, &test_power_supplies[i]);
if (ret) { if (ret) {
...@@ -309,7 +320,7 @@ static inline void signal_power_supply_changed(struct power_supply *psy) ...@@ -309,7 +320,7 @@ static inline void signal_power_supply_changed(struct power_supply *psy)
static int param_set_ac_online(const char *key, const struct kernel_param *kp) static int param_set_ac_online(const char *key, const struct kernel_param *kp)
{ {
ac_online = map_get_value(map_ac_online, key, ac_online); ac_online = map_get_value(map_ac_online, key, ac_online);
signal_power_supply_changed(&test_power_supplies[0]); signal_power_supply_changed(&test_power_supplies[TEST_AC]);
return 0; return 0;
} }
...@@ -322,7 +333,7 @@ static int param_get_ac_online(char *buffer, const struct kernel_param *kp) ...@@ -322,7 +333,7 @@ static int param_get_ac_online(char *buffer, const struct kernel_param *kp)
static int param_set_usb_online(const char *key, const struct kernel_param *kp) static int param_set_usb_online(const char *key, const struct kernel_param *kp)
{ {
usb_online = map_get_value(map_ac_online, key, usb_online); usb_online = map_get_value(map_ac_online, key, usb_online);
signal_power_supply_changed(&test_power_supplies[2]); signal_power_supply_changed(&test_power_supplies[TEST_USB]);
return 0; return 0;
} }
...@@ -336,7 +347,7 @@ static int param_set_battery_status(const char *key, ...@@ -336,7 +347,7 @@ static int param_set_battery_status(const char *key,
const struct kernel_param *kp) const struct kernel_param *kp)
{ {
battery_status = map_get_value(map_status, key, battery_status); battery_status = map_get_value(map_status, key, battery_status);
signal_power_supply_changed(&test_power_supplies[1]); signal_power_supply_changed(&test_power_supplies[TEST_BATTERY]);
return 0; return 0;
} }
...@@ -350,7 +361,7 @@ static int param_set_battery_health(const char *key, ...@@ -350,7 +361,7 @@ static int param_set_battery_health(const char *key,
const struct kernel_param *kp) const struct kernel_param *kp)
{ {
battery_health = map_get_value(map_health, key, battery_health); battery_health = map_get_value(map_health, key, battery_health);
signal_power_supply_changed(&test_power_supplies[1]); signal_power_supply_changed(&test_power_supplies[TEST_BATTERY]);
return 0; return 0;
} }
...@@ -364,7 +375,7 @@ static int param_set_battery_present(const char *key, ...@@ -364,7 +375,7 @@ static int param_set_battery_present(const char *key,
const struct kernel_param *kp) const struct kernel_param *kp)
{ {
battery_present = map_get_value(map_present, key, battery_present); battery_present = map_get_value(map_present, key, battery_present);
signal_power_supply_changed(&test_power_supplies[0]); signal_power_supply_changed(&test_power_supplies[TEST_AC]);
return 0; return 0;
} }
...@@ -380,7 +391,7 @@ static int param_set_battery_technology(const char *key, ...@@ -380,7 +391,7 @@ static int param_set_battery_technology(const char *key,
{ {
battery_technology = map_get_value(map_technology, key, battery_technology = map_get_value(map_technology, key,
battery_technology); battery_technology);
signal_power_supply_changed(&test_power_supplies[1]); signal_power_supply_changed(&test_power_supplies[TEST_BATTERY]);
return 0; return 0;
} }
...@@ -401,7 +412,7 @@ static int param_set_battery_capacity(const char *key, ...@@ -401,7 +412,7 @@ static int param_set_battery_capacity(const char *key,
return -EINVAL; return -EINVAL;
battery_capacity = tmp; battery_capacity = tmp;
signal_power_supply_changed(&test_power_supplies[1]); signal_power_supply_changed(&test_power_supplies[TEST_BATTERY]);
return 0; return 0;
} }
...@@ -416,7 +427,7 @@ static int param_set_battery_voltage(const char *key, ...@@ -416,7 +427,7 @@ static int param_set_battery_voltage(const char *key,
return -EINVAL; return -EINVAL;
battery_voltage = tmp; battery_voltage = tmp;
signal_power_supply_changed(&test_power_supplies[1]); signal_power_supply_changed(&test_power_supplies[TEST_BATTERY]);
return 0; return 0;
} }
......
...@@ -461,7 +461,6 @@ struct ab8500_fg; ...@@ -461,7 +461,6 @@ struct ab8500_fg;
#ifdef CONFIG_AB8500_BM #ifdef CONFIG_AB8500_BM
extern struct abx500_bm_data ab8500_bm_data; extern struct abx500_bm_data ab8500_bm_data;
void ab8500_fg_reinit(void);
void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA);
struct ab8500_btemp *ab8500_btemp_get(void); struct ab8500_btemp *ab8500_btemp_get(void);
int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp); int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp);
......
...@@ -143,10 +143,118 @@ enum max77693_pmic_reg { ...@@ -143,10 +143,118 @@ enum max77693_pmic_reg {
#define FLASH_INT_FLED1_SHORT BIT(3) #define FLASH_INT_FLED1_SHORT BIT(3)
#define FLASH_INT_OVER_CURRENT BIT(4) #define FLASH_INT_OVER_CURRENT BIT(4)
/* Fast charge timer in in hours */
#define DEFAULT_FAST_CHARGE_TIMER 4
/* microamps */
#define DEFAULT_TOP_OFF_THRESHOLD_CURRENT 150000
/* minutes */
#define DEFAULT_TOP_OFF_TIMER 30
/* microvolts */
#define DEFAULT_CONSTANT_VOLT 4200000
/* microvolts */
#define DEFAULT_MIN_SYSTEM_VOLT 3600000
/* celsius */
#define DEFAULT_THERMAL_REGULATION_TEMP 100
/* microamps */
#define DEFAULT_BATTERY_OVERCURRENT 3500000
/* microvolts */
#define DEFAULT_CHARGER_INPUT_THRESHOLD_VOLT 4300000
/* MAX77693_CHG_REG_CHG_INT_OK register */
#define CHG_INT_OK_BYP_SHIFT 0
#define CHG_INT_OK_BAT_SHIFT 3
#define CHG_INT_OK_CHG_SHIFT 4
#define CHG_INT_OK_CHGIN_SHIFT 6
#define CHG_INT_OK_DETBAT_SHIFT 7
#define CHG_INT_OK_BYP_MASK BIT(CHG_INT_OK_BYP_SHIFT)
#define CHG_INT_OK_BAT_MASK BIT(CHG_INT_OK_BAT_SHIFT)
#define CHG_INT_OK_CHG_MASK BIT(CHG_INT_OK_CHG_SHIFT)
#define CHG_INT_OK_CHGIN_MASK BIT(CHG_INT_OK_CHGIN_SHIFT)
#define CHG_INT_OK_DETBAT_MASK BIT(CHG_INT_OK_DETBAT_SHIFT)
/* MAX77693_CHG_REG_CHG_DETAILS_00 register */
#define CHG_DETAILS_00_CHGIN_SHIFT 5
#define CHG_DETAILS_00_CHGIN_MASK (0x3 << CHG_DETAILS_00_CHGIN_SHIFT)
/* MAX77693_CHG_REG_CHG_DETAILS_01 register */
#define CHG_DETAILS_01_CHG_SHIFT 0
#define CHG_DETAILS_01_BAT_SHIFT 4
#define CHG_DETAILS_01_TREG_SHIFT 7
#define CHG_DETAILS_01_CHG_MASK (0xf << CHG_DETAILS_01_CHG_SHIFT)
#define CHG_DETAILS_01_BAT_MASK (0x7 << CHG_DETAILS_01_BAT_SHIFT)
#define CHG_DETAILS_01_TREG_MASK BIT(7)
/* MAX77693_CHG_REG_CHG_DETAILS_01/CHG field */
enum max77693_charger_charging_state {
MAX77693_CHARGING_PREQUALIFICATION = 0x0,
MAX77693_CHARGING_FAST_CONST_CURRENT,
MAX77693_CHARGING_FAST_CONST_VOLTAGE,
MAX77693_CHARGING_TOP_OFF,
MAX77693_CHARGING_DONE,
MAX77693_CHARGING_HIGH_TEMP,
MAX77693_CHARGING_TIMER_EXPIRED,
MAX77693_CHARGING_THERMISTOR_SUSPEND,
MAX77693_CHARGING_OFF,
MAX77693_CHARGING_RESERVED,
MAX77693_CHARGING_OVER_TEMP,
MAX77693_CHARGING_WATCHDOG_EXPIRED,
};
/* MAX77693_CHG_REG_CHG_DETAILS_01/BAT field */
enum max77693_charger_battery_state {
MAX77693_BATTERY_NOBAT = 0x0,
/* Dead-battery or low-battery prequalification */
MAX77693_BATTERY_PREQUALIFICATION,
MAX77693_BATTERY_TIMER_EXPIRED,
MAX77693_BATTERY_GOOD,
MAX77693_BATTERY_LOWVOLTAGE,
MAX77693_BATTERY_OVERVOLTAGE,
MAX77693_BATTERY_OVERCURRENT,
MAX77693_BATTERY_RESERVED,
};
/* MAX77693_CHG_REG_CHG_DETAILS_02 register */
#define CHG_DETAILS_02_BYP_SHIFT 0
#define CHG_DETAILS_02_BYP_MASK (0xf << CHG_DETAILS_02_BYP_SHIFT)
/* MAX77693 CHG_CNFG_00 register */ /* MAX77693 CHG_CNFG_00 register */
#define CHG_CNFG_00_CHG_MASK 0x1 #define CHG_CNFG_00_CHG_MASK 0x1
#define CHG_CNFG_00_BUCK_MASK 0x4 #define CHG_CNFG_00_BUCK_MASK 0x4
/* MAX77693_CHG_REG_CHG_CNFG_01 register */
#define CHG_CNFG_01_FCHGTIME_SHIFT 0
#define CHG_CNFG_01_CHGRSTRT_SHIFT 4
#define CHG_CNFG_01_PQEN_SHIFT 7
#define CHG_CNFG_01_FCHGTIME_MASK (0x7 << CHG_CNFG_01_FCHGTIME_SHIFT)
#define CHG_CNFG_01_CHGRSTRT_MASK (0x3 << CHG_CNFG_01_CHGRSTRT_SHIFT)
#define CHG_CNFG_01_PQEN_MAKS BIT(CHG_CNFG_01_PQEN_SHIFT)
/* MAX77693_CHG_REG_CHG_CNFG_03 register */
#define CHG_CNFG_03_TOITH_SHIFT 0
#define CHG_CNFG_03_TOTIME_SHIFT 3
#define CHG_CNFG_03_TOITH_MASK (0x7 << CHG_CNFG_03_TOITH_SHIFT)
#define CHG_CNFG_03_TOTIME_MASK (0x7 << CHG_CNFG_03_TOTIME_SHIFT)
/* MAX77693_CHG_REG_CHG_CNFG_04 register */
#define CHG_CNFG_04_CHGCVPRM_SHIFT 0
#define CHG_CNFG_04_MINVSYS_SHIFT 5
#define CHG_CNFG_04_CHGCVPRM_MASK (0x1f << CHG_CNFG_04_CHGCVPRM_SHIFT)
#define CHG_CNFG_04_MINVSYS_MASK (0x7 << CHG_CNFG_04_MINVSYS_SHIFT)
/* MAX77693_CHG_REG_CHG_CNFG_06 register */
#define CHG_CNFG_06_CHGPROT_SHIFT 2
#define CHG_CNFG_06_CHGPROT_MASK (0x3 << CHG_CNFG_06_CHGPROT_SHIFT)
/* MAX77693_CHG_REG_CHG_CNFG_07 register */
#define CHG_CNFG_07_REGTEMP_SHIFT 5
#define CHG_CNFG_07_REGTEMP_MASK (0x3 << CHG_CNFG_07_REGTEMP_SHIFT)
/* MAX77693_CHG_REG_CHG_CNFG_12 register */
#define CHG_CNFG_12_B2SOVRC_SHIFT 0
#define CHG_CNFG_12_VCHGINREG_SHIFT 3
#define CHG_CNFG_12_B2SOVRC_MASK (0x7 << CHG_CNFG_12_B2SOVRC_SHIFT)
#define CHG_CNFG_12_VCHGINREG_MASK (0x3 << CHG_CNFG_12_VCHGINREG_SHIFT)
/* MAX77693 CHG_CNFG_09 Register */ /* MAX77693 CHG_CNFG_09 Register */
#define CHG_CNFG_09_CHGIN_ILIM_MASK 0x7F #define CHG_CNFG_09_CHGIN_ILIM_MASK 0x7F
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/power_supply.h> #include <linux/power_supply.h>
#include <linux/extcon.h> #include <linux/extcon.h>
#include <linux/alarmtimer.h>
enum data_source { enum data_source {
CM_BATTERY_PRESENT, CM_BATTERY_PRESENT,
...@@ -44,29 +45,6 @@ enum cm_event_types { ...@@ -44,29 +45,6 @@ enum cm_event_types {
CM_EVENT_OTHERS, CM_EVENT_OTHERS,
}; };
/**
* struct charger_global_desc
* @rtc_name: the name of RTC used to wake up the system from suspend.
* @rtc_only_wakeup:
* If the system is woken up by waekup-sources other than the RTC or
* callbacks, Charger Manager should recognize with
* rtc_only_wakeup() returning false.
* If the RTC given to CM is the only wakeup reason,
* rtc_only_wakeup should return true.
* @assume_timer_stops_in_suspend:
* Assume that the jiffy timer stops in suspend-to-RAM.
* When enabled, CM does not rely on jiffies value in
* suspend_again and assumes that jiffies value does not
* change during suspend.
*/
struct charger_global_desc {
char *rtc_name;
bool (*rtc_only_wakeup)(void);
bool assume_timer_stops_in_suspend;
};
/** /**
* struct charger_cable * struct charger_cable
* @extcon_name: the name of extcon device. * @extcon_name: the name of extcon device.
...@@ -266,22 +244,14 @@ struct charger_manager { ...@@ -266,22 +244,14 @@ struct charger_manager {
char psy_name_buf[PSY_NAME_MAX + 1]; char psy_name_buf[PSY_NAME_MAX + 1];
struct power_supply charger_psy; struct power_supply charger_psy;
bool status_save_ext_pwr_inserted;
bool status_save_batt;
u64 charging_start_time; u64 charging_start_time;
u64 charging_end_time; u64 charging_end_time;
}; };
#ifdef CONFIG_CHARGER_MANAGER #ifdef CONFIG_CHARGER_MANAGER
extern int setup_charger_manager(struct charger_global_desc *gd);
extern bool cm_suspend_again(void);
extern void cm_notify_event(struct power_supply *psy, extern void cm_notify_event(struct power_supply *psy,
enum cm_event_types type, char *msg); enum cm_event_types type, char *msg);
#else #else
static inline int setup_charger_manager(struct charger_global_desc *gd)
{ return 0; }
static inline bool cm_suspend_again(void) { return false; }
static inline void cm_notify_event(struct power_supply *psy, static inline void cm_notify_event(struct power_supply *psy,
enum cm_event_types type, char *msg) { } enum cm_event_types type, char *msg) { }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment