Commit graph

118 commits

Author SHA1 Message Date
Jun Nie 3309aa4941 power/reset: zx: Remove unnecessary include file
Including ARM related header file cause build failure
in i386 build because COMILE_TEST also involve building
zx driver. Remove the unnecessary include file.

Signed-off-by: Jun Nie <jun.nie@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-07-27 15:33:30 +02:00
Jun Nie dd9f1486ae power/reset: zx: Register restart handler
Register with kernel restart handler instead of setting arm_pm_restart
directly.

Signed-off-by: Jun Nie <jun.nie@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-07-24 17:29:17 +02:00
Josh Wu 1ae25d626c power: reset: at91: add sama5d3 reset function
This patch introduces a new compatible string: "atmel,sama5d3-rstc" and
new reset function for sama5d3 and later chips.

As in sama5d3 or later chips, we don't have to shutdown the DDR
controller before reset. Shutdown the DDR controller before reset is a
workaround to avoid DDR signal driving the bus, but since sama5d3 and
later chips there is no such a conflict.

So in this patch:
   1. the sama5d3 reset function only need to write the rstc register
and return.
   2. we can remove the code related with sama5d3 DDR controller as
we don't use it at all.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-07-20 18:12:09 +02:00
Linus Torvalds 75462c8a87 Replace module_platform_driver with builtin_platform driver in non modules.
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJVkO9lAAoJEOvOhAQsB9HWRV4P/jYrQm/S14ZfbwzqwV2w5xh+
 E1SHk+kjcLyIvG6JXknp8mlNFGFhsIZNhTq8wvYBmFHlkop9jlMqT3IwaV7y9baV
 NmxltPHVIgFhnPMBF6+nvMJVFe0oBXh3adwc02h/LcXauEPK98Na/BtAfX5nxmoy
 DO/9R+R3SxqShSHvQqM6JNu3M/xAxU7RRSMsthF3nZJfZEm5i7Sl9w6Zcmu67gEn
 KbAPmthHSzDvJZGPt6xQiR2OPvhdA2Ddxjey0/cLyl/IVd2DdUTUUHDY0lUpPd3A
 Ba6C6OaWoHbCoAVzGvXEJLP1CfuF5upTmo53FZ2+1fERzX7Co4E2xInq6qkpWK5+
 cLcqCZaxHXvmvmidrfTaJQ52dLseGAH5KsiDoR8m5RcsCMrK367V6ja5/A2UG+xW
 FVJzU7/1LRHzw17si/AcrD0Q3hFR0n6klEGS3E964fsyOuCYlSc77IspxZ7nF4QW
 cFKKweyAUdrmrlduS7rKxX4z/ne4ljbR1M82YxFVPWqg/n2cqQ4e9RQFeK8ogBe6
 ASXu6pmz03X5xoD7xPQEsVzjDDGPzGFdD/601j9cRJ0+TR9udECP776gXt+5Ml0L
 jWlhVGbt7BN64UFZ/kInGo1h6cS+JjlrBfNq6eZVQP78bZ5UWdyiupGzcLcixefN
 bnkl2MHHY/d6yk2Rs7zh
 =WLBw
 -----END PGP SIGNATURE-----

Merge tag 'module-builtin_driver-v4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux

Pull module_platform_driver replacement from Paul Gortmaker:
 "Replace module_platform_driver with builtin_platform driver in non
  modules.

  We see an increasing number of non-modular drivers using
  modular_driver() type register functions.  There are several downsides
  to letting this continue unchecked:

   - The code can appear modular to a reader of the code, and they won't
     know if the code really is modular without checking the Makefile
     and Kconfig to see if compilation is governed by a bool or
     tristate.

   - Coders of drivers may be tempted to code up an __exit function that
     is never used, just in order to satisfy the required three args of
     the modular registration function.

   - Non-modular code ends up including the <module.h> which increases
     CPP overhead that they don't need.

   - It hinders us from performing better separation of the module init
     code and the generic init code.

  So here we introduce similar macros for builtin drivers.  Then we
  convert builtin drivers (controlled by a bool Kconfig) by making the
  following type of mapping:

    module_platform_driver()       --->  builtin_platform_driver()
    module_platform_driver_probe() --->  builtin_platform_driver_probe().

  The set of drivers that are converted here are just the ones that
  showed up as relying on an implicit include of <module.h> during a
  pending header cleanup.  So we convert them here vs adding an include
  of <module.h> to non-modular code to avoid compile fails.  Additonal
  conversions can be done asynchronously at any time.

  Once again, an unused module_exit function that is removed here
  appears in the diffstat as an outlier wrt all the other changes"

* tag 'module-builtin_driver-v4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux:
  drivers/clk: convert sunxi/clk-mod0.c to use builtin_platform_driver
  drivers/power: Convert non-modular syscon-reboot to use builtin_platform_driver
  drivers/soc: Convert non-modular soc-realview to use builtin_platform_driver
  drivers/soc: Convert non-modular tegra/pmc to use builtin_platform_driver
  drivers/cpufreq: Convert non-modular s5pv210-cpufreq.c to use builtin_platform_driver
  drivers/cpuidle: Convert non-modular drivers to use builtin_platform_driver
  drivers/platform: Convert non-modular pdev_bus to use builtin_platform_driver
  platform_device: better support builtin boilerplate avoidance
2015-07-02 10:42:13 -07:00
Linus Torvalds 36a1624d88 power supply and reset changes for the v4.2 series
* New charger drivers: BQ24257, BQ25890, AXP288, RT9455
  * MAX17042 battery: add health & temperature support
  * BQ2415x charger: add ACPI support
  * misc. fixes and cleanups
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCgAGBQJViI++AAoJENju1/PIO/qasPYP/0YMZdNNEUA/z1Uv8litaGbe
 gCzLRKuevt/996eVQcGJwsla/7AZwNgpUJya28mpiRqp+RbsTB4bkiGCkD2aO2Jw
 p34h9tIugU5H8+iL1+vl/ztpjwwm/bxEQHNpHK/YwqQLP7QazI6/yyRAUzYu0bGk
 RUndaStY/UZ/9KtSfGYF54kpxCXVQS0aHPMXXKQREr3Hg/VMlBoKQeAvJ7jTTjST
 7s9ZncO70jeY1NrSSdRY+anbuUNYqt0ndbaHhlpayGxnWL+PGdd2mNKq/ycGmBld
 8PwnDs+6fLv24PGYnkwbTryCbdvU9ZYUuNVb4XNTY+8x8CSPNuM8yYhqkmmq1dfI
 zXy1U9TCkLtKSk+7rxKWZc0WuWn2D9UJvr1zAoK9TMafdLi3YIMbm1TemKpLX/HJ
 chORnioPNgBiLmSzJ+nizWfWU5BQ5MhJamzhER0dRG9u8/2YJzCyNfd2miGrvAdL
 LecLcWopEDa+cAg5HM3usKcv0GsBJIes/jmtSMv2URWk8FHcXsDMsnl+D/77/LmV
 PM+HNJ/cNi7WGMgMO6lb1gULaRdAb6tZS865p2Abx5NkNjjRQw9A8EIwP30SPWh7
 aPhU6jxDdmhpez4nJeyHdjcQqnlE+Cxz9vwj8IMgneTjSl4guUY1HcgmAHJtrKGC
 WNB/r32UzJ5AZ0VxBB15
 =192M
 -----END PGP SIGNATURE-----

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

Pull power supply and reset updates from Sebastian Reichel:

 - new charger drivers: BQ24257, BQ25890, AXP288, RT9455

 - MAX17042 battery: add health & temperature support

 - BQ2415x charger: add ACPI support

 - misc fixes and cleanups

* tag 'for-4.2' of git://git.infradead.org/battery-2.6: (32 commits)
  power_supply: Correct kerneldoc copy paste errors
  wm831x_power: Fix off-by-one at free_irq()
  power_supply: rt9455_charger: Fix error reported by static analysis tool
  power_supply: bq24257: use flags argument of devm_gpiod_get
  power_supply: bq25890: use flags argument of devm_gpiod_get
  sbs-battery: add option to always register battery
  power: Add devm_power_supply_get_by_phandle() helper function
  power_supply: max17042: Add OF support for setting thresholds
  power_supply: sysfs: Bring back write to writeable properties
  power_supply: rt9455_charger: Check if CONFIG_USB_PHY is enabled
  power: reset: gpio-restart: increase priority slightly
  power_supply: bq25890: make chip_id int
  power_supply: Add support for Richtek RT9455 battery charger
  Documentation: devicetree: Add Richtek RT9455 bindings
  of: Add vendor prefix for Richtek Technology Corporation
  power_supply: 88pm860x_charger: Do not call free_irq() twice
  power: bq24190_charger: Change first_time flag reset condition
  power: axp288_charger: axp288 charger driver
  power: max17042_battery: add HEALTH and TEMP_* properties support
  power_supply: Add support for TI BQ25890 charger chip
  ...
2015-06-23 16:10:27 -07:00
Paul Gortmaker e35415e59f drivers/power: Convert non-modular syscon-reboot to use builtin_platform_driver
This file depends on Kconfig options all of which are a bool, so
we use the appropriate registration function, which avoids us
relying on an implicit inclusion of <module.h> which we are
doing currently.

While this currently works, we really don't want to be including
the module.h header in non-modular code, which we'd be forced
to do, pending some upcoming code relocation from init.h into
module.h.  So we fix it now by using the non-modular equivalent.

Cc: Sebastian Reichel <sre@kernel.org>
Acked-By: Sebastian Reichel <sre@kernel.org>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2015-06-16 14:12:38 -04:00
Heiko Stübner bcd56fe1aa power: reset: gpio-restart: increase priority slightly
gpio-restart uses a priority of 128 and currently most soc-level restart
mechanisms use the same - with some exceptions even using 192.
But while the soc-level restarts are provided by the soc itself,
gpio-restarts will most of the time be board-specfic and be used
when some special board condition makes the soc-level restart
only a second choice.

The problem at hand manifested itself on the rk3288-veyron devices.
While the soc-level restart can sucessfully restart all other rockchip
boards I have, the veyron devices use an external restart mechanism that
seems to not only reset the soc but also some external needed components.

With both restart handlers having priority 128 in my tests the soc-specific
variant took precedent in all cases. While it could restart the soc
sucessfully in all cases, firmware then got an issue when talking to an
external component, resulting in the device being put into recovery mode.

So, give the board-specific restart handler a slight push and move it
to priority 129 to make it more important than the generic soc-specific
restart-handler.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-06-02 20:59:03 +02:00
Uwe Kleine-König 9f6cd98fc3 power: reset: ltc2952: use _optional variant of devm_gpiod_get
devm_gpiod_get_optional returns NULL if devm_gpiod_get would return an
ENOENT error pointer.

There is no semantic change intended.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 20:03:42 +02:00
Uwe Kleine-König a34c0a8bf8 power: reset: gpio-poweroff: let devm_gpiod_get set direction of gpio
Since 39b2bbe3d7 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 20:03:30 +02:00
Krzysztof Kozlowski 3236672092 power: at91-reset: Constify platform_device_id
The platform_device_id is not modified by the driver and core uses it as
const.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-23 19:44:23 +02:00
Thomas Gleixner c3b5d3cea5 Merge branch 'linus' into timers/core
Make sure the upstream fixes are applied before adding further
modifications.
2015-05-19 16:12:32 +02:00
Florian Fainelli 0a73125d30 power: reset: Add MFD_SYSCON depends for brcmstb
The Broadcom STB reboot driver depends on MFD_SYSCON, it uses
syscon_regmap_lookup_by_phandle() which will not lookup syscon phandles
if MFD_SYSCON is disabled, and instead will return -ENOSYS since it is
turned into an inline stub.

Fixes: 030494e750 ("power: reset: Add reboot driver for brcmstb")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-05-01 22:48:28 +02:00
Thomas Gleixner d8818257d3 power: reset: ltc2952: Remove bogus hrtimer_start() return value checks
The return value of hrtimer_start() tells whether the timer was
inactive or active already when hrtimer_start() was called.

The code emits a bogus warning if the timer was active already
claiming that the timer could not be started.

Remove it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Frans Klaver <frans.klaver@xsens.com>
Cc: "René Moll" <linux@r-moll.nl>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-pm@vger.kernel.org
Acked-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-30 17:47:17 +02:00
Wei Yongjun 932df43005 power/reset: at91: fix return value check in at91_reset_platform_probe()
In case of error, the function devm_ioremap() returns NULL
not ERR_PTR(). The IS_ERR() test in the return value check
should be replaced with NULL test.

Fixes: ecfe64d8c5 ("power: reset: Add AT91 reset driver")
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-30 17:33:52 +02:00
Thomas Gleixner 4101ecc23d power: reset: ltc2952: Remove bogus hrtimer_start() return value checks
The return value of hrtimer_start() tells whether the timer was
inactive or active already when hrtimer_start() was called.

The code emits a bogus warning if the timer was active already
claiming that the timer could not be started.

Remove it along with the bogus comment in the else path.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Frans Klaver <frans.klaver@xsens.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-pm@vger.kernel.org
2015-04-23 14:38:01 +02:00
Moritz Fischer 8a577608ba power: reset: Add generic SYSCON register mapped poweroff.
Add a generic SYSCON register mapped poweroff mechanism.

Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-04-06 18:49:48 +02:00
Ben Dooks 7be5ac2c32 power/reset: at91: big endian fixes for atsama5d3x
Fix the passing of big endian data to routines that will be writing
it to the bus in the wrong order.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-03-26 15:21:00 +01:00
Fabian Frederick 8fb0885504 power: constify of_device_id array
of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

Signed-off-by: Fabian Frederick <fabf@skynet.be>

[for vexpress]
Acked-by: Sudeep Holla <sudeep.holla@arm.com>

Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-03-20 13:23:06 +01:00
Richard Weinberger 039ab50bda power/reset/rmobile-reset.c: Fix !HAS_IOMEM build
Fixes:
drivers/power/reset/rmobile-reset.c: In function ‘rmobile_reset_probe’:
drivers/power/reset/rmobile-reset.c:61:2: error: implicit declaration of function ‘iounmap’ [-Werror=implicit-function-declaration]
  iounmap(sysc_base2);

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-03-20 13:06:01 +01:00
Guenter Roeck 7bae8f0481 power/reset: restart-poweroff: Remove arm dependencies
This driver is now arm specific anymore, so there is no need to include
an arm specific include file. Also drop unnecessary depencency on ARM
from Kconfig.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-25 22:13:18 +01:00
Guenter Roeck 7fa650bc0d power/reset: st-poweroff: Fix misleading Kconfig description
The st-poweroff driver does not really power off the system
but resets it, so Kconfig should not claim that the driver
would handle power-off.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-25 22:13:17 +01:00
Guenter Roeck 453fe4f11c power/reset: st-poweroff: Register with kernel restart handler
Register with kernel restart handler instead of setting arm_pm_restart
directly. Select high priority since the restart handler is instantiated
through devicetree, indicating that it should be used if configured.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-25 22:13:16 +01:00
Guenter Roeck b2b3a8b934 power/reset: Remove sun6i reboot driver
sun6i restart is now handled by its watchdog driver directly,
so this driver is no longer needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-25 22:13:07 +01:00
Guenter Roeck 481ff6ff96 power/reset: at91: Register with kernel restart handler
Register with kernel restart handler instead of setting arm_pm_restart
directly. Register with high priority since the driver unconditionally
overwrites other restart handlers if instantiated.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-25 22:12:45 +01:00
Guenter Roeck 25a5b57dd7 power/reset: arm-versatile: Register with kernel restart handler
Register with kernel restart handler instead of setting arm_pm_restart
directly. Select high priority since the restart handler is instantiated
through devicetree, indicating that it should be used if configured.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-25 22:12:45 +01:00
Kevin Cernekee 79969f6aaf power/reset: brcmstb: Add support for old 65nm chips
The register bit fields are a little different, so add an entry and a
compatible string to accommodate them.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-22 02:25:32 +01:00
Kevin Cernekee bb1de7f61f power/reset: brcmstb: Use the DT "compatible" string to indicate bit positions
Some of the older chips used different bits to arm and trigger the reset.
Add the infrastructure needed to specify this through the "compatible"
string.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-22 02:25:32 +01:00
Kevin Cernekee 4f5fd64046 power/reset: brcmstb: Make the driver buildable on MIPS
Now that the driver doesn't use any ARM-specific headers, it is safe
to build on MIPS or with COMPILE_TEST.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-22 02:25:31 +01:00
Guenter Roeck a538cf04ef power/reset: at91-poweroff: Fix error handling and other compiler warnings
at91_poweroff_get_wakeup_mode can return a negative error code and should
therefore not return an enum type. Similar, its result should not be
assigned to an enum type. Otherwise, the returned value is never negative,
resulting in a compiler warning and a missed error condition, which in turn
results in writing bad values into a chip register.

Also fix other compiler warnings which can be easily avoided.

drivers/power/reset/at91-poweroff.c:74:24:
	warning: type qualifiers ignored on function return type
drivers/power/reset/at91-poweroff.c:74:24:
	warning: no previous prototype for 'at91_poweroff_get_wakeup_mode'
drivers/power/reset/at91-poweroff.c:83:16:
	warning: comparison between signed and unsigned integer expressions
drivers/power/reset/at91-poweroff.c:97:2:
	warning: comparison of unsigned expression < 0 is always false

Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-21 20:06:44 +01:00
Geert Uytterhoeven fa0f8d6700 power: reset: Add reset driver for R-Mobile platforms
Add a reset driver for Renesas R-Mobile and SH-Mobile SoCs. It registers
a restart handler to trigger a soft power-on reset through the R-Mobile
System Controller.
The priority of this restart handler is 192, to allow a watchdog driver
to use priority 128.

Note that we do not use syscon-reboot, as the HPB (Peripheral Bus
Bridge) semaphore should be acquired on systems where both the ARM and
SH core are in use. The driver can be extended later to support this,
when needed.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-21 16:32:05 +01:00
Pawel Moll 8f961c0a53 power/reset: vexpress: Remove non-DT code
Now, as all VE platforms have to be booted with DT,
the code handling non-DT case can be removed.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-21 03:19:54 +01:00
Frans Klaver ee18185331 power: reset: ltc2952: make trigger input optional
Currently the ltc2952 supports only one button sequence to initiate
powerdown. This is not always desirable, as even prolonged button
presses can happen in use.

Allow ltc2952 users to pick their own power down sequence, by making the
trigger input optional. Since this still means that the ltc2952 may
power down the platform if the power button is pressed for about 5
seconds, we still need to make sure to start the watchdog toggle to
prolong the system power for as long as we need it.

This will still allow the system to control power using the kill signal.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:31 +01:00
Frans Klaver c1ada2ff80 power: reset: ltc2952: check trigger value before starting timer
In ltc2952_poweroff_handler it is theoretically possible that the timer
fails to start on first pass (button press), but succeeds in starting on
the second (button release). This will cause the button press to be
misinterpreted, and will incorrectly shut down the system. Because a
picture says more than a thousand words:

Expected behavior:
tmr:      ++++++++++
btn: -----__________-----

Faulty behavior:
tmr:                +++++
btn: -----__________-----

Legend:
+ timer runs
_ button pressed
- button depressed

To prevent this from happening, check the value of the gpio before
starting the timer. If the button is active, we should start the timer,
else we should stop it.

The situation described can now still occur if the polarity of the input
pin is set incorrectly, but that at least is predictable behavior and
can be detected during the first tests.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:30 +01:00
Frans Klaver 2f6ea8ad73 power: reset: ltc2952: disable timers in _remove
Disable the timers when ltc2952_poweroff is removed. We don't want to
risk calling functions on data that no longer exist.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:30 +01:00
Frans Klaver 5689b786f7 power: reset: ltc2952: fix C++ style function pointers
The function pointers for the timers and pm_power_off are assigned with
C++ style
	foo = &func;

Let's change it instead to the more C style
	foo = func;

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:30 +01:00
Frans Klaver 5c3faad29b power: reset: ltc2952: cleanup control flow in poweroff_handler
ltc2952_poweroff_handler uses gotos to return from the function. Since
we don't do cleanups exiting this function, just return IRQ_HANDLED on
the spot and be done with it.

While at it, remove the variable 'ret'. It was never used very much.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:30 +01:00
Frans Klaver 0428c40d4c power: reset: ltc2952: drop empty suspend/resume functions
Documentation/SubmittingDrivers suggests these be implemented even when
they do nothing. On the other hand, the platform code calls these
functions 'legacy'. Suspend and resume operations should go into a
pm_ops structure, pointed at by the driver's pm field. This approach
would lead to a lot of boiler plate, while achieving nothing. Drop the
functions instead.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:29 +01:00
Frans Klaver 818ca4c8c7 power: reset: ltc2952: remove global variable poweroff_panic
As per Documentation/CodingStyle ch.4, we should keep global variables
to a mininum. Move the panic state into the driver data, regardless of
whether panic is a system state or not.

This removes the need for the custom _init and _exit functions, so
replace them with a call to the module_platform_driver() macro.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:28 +01:00
Frans Klaver a5f67be520 power: reset: ltc2952: reduce dependency on global variables
Documentation/CodingStyle ch.4 mentions in a side node that global
variables should only be used if you really need them. Reduce the use of
the global instance of ltc2952_poweroff so we may eventually remove it
entirely.

While at it, rename ltc2952_poweroff_data to ltc2952_poweroff, just to
save that little bit of typing.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:28 +01:00
Frans Klaver 62113b3117 power: reset: ltc2952: prefer devm_gpiod_get over gpiod_get
This reduces cleanup code and chance of errors.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:28 +01:00
Frans Klaver f66472df69 power: reset: ltc2952: unroll gpio_desc array
The three gpio's used by this driver are stored in an array of pointers.
This doesn't add much besides cleanups in a loop. In fact, it makes most
of the usage sites harder to read. Unroll the loop, and live with the
fact that cleanups become slightly larger.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:28 +01:00
Frans Klaver 07d08237d3 power: reset: ltc2952: prefer devm_request_irq over request_irq
Make use of the fact that we allocated resources can be automatically
deallocated. This reduces cleanup code and chance of errors. It also
removes the need for the virq member of the ltc2952_poweroff_data
struct.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:28 +01:00
Frans Klaver 0a5c6a2276 power: reset: ltc2952: prefer devm_kzalloc over kzalloc
Make use of the fact that the allocated resources can be automatically
deallocated. This reduces cleanup code and chance of leaks.

Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:27 +01:00
Linus Walleij 0160817d10 power: reset: augment versatile driver for integrator
Augment the Versatile reset driver to also handle the core
module reset sequence used on the Integrator/AP and
Integrator/CP.

Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-01-20 13:58:27 +01:00
Linus Torvalds 7051d8e630 power supply and reset changes for the v3.19 series
* update power/reset drivers to use kernel restart handler
 * add power off driver for i.mx6
 * add DT support for gpio-charger
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABCgAGBQJUjv52AAoJENju1/PIO/qaESIP/3rRE/Gw1fmfX+F1wN+jXQao
 WXw2JW/IUQG0TQlpTnEqPQQu+H48dX58MbpNVSLy2O7Z4XiMRDG2HkEduyJYGm+P
 37pfgiTH9Vj7MJ0EnNK3lLrQmF1l+yNHIjZUGLPEjbKmXSzJYPHwNhtC5U9/QooY
 igRwKC51bBw6of6pPaIYP6nxQeaNVgI3MaOnJ1+glLc0uQuy5mc4gODL6yCEkvuR
 WCsyJi226m/dBD+ZgejSet7kJS3JG4dR0GuqZkJ22DS5wKbwKrgXfOiVl+xrgCwR
 FqbvnZbscr+jt/xFJsAT5zqtvHNgxx37XVwkV3nHsKX8UugYg3rCB5T/mlgNj+m/
 Cg5BePP84O1NMJHYXSj7Wo6BYYoFJO8ucT0uIKpcci3UyvtqWcMXzptNjkAtylw1
 P+0EtP7HL4jBLJ5Snd0Je47w2mztmaJmqCc9LU8odznlFbaJ25X3chf3zqAoKdpY
 Lqe1XWxi5HtLNmuX/NsNhw0tdxuSiH5e2r7yM5Bwtm4uh4Yx9Ab9TEtloF3u+en5
 ALR88cryxbP0zu0K/HFUeoM3v7mqH3x29NqAsSpY1D6p87308FUa1rkvYMlHwcFD
 Y2W2iZhmxnE5Bi9OTpfDgGQYNEUiELWmMDi3S3aSwb0QM9UWsi043LGMQfpG5QCn
 +xKTKJDNJsHAX5jYDuDY
 =v7l/
 -----END PGP SIGNATURE-----

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

Pull power supply updates from Sebastian Reichel::
 "Power supply and reset changes for the v3.19 series

   - update power/reset drivers to use kernel restart handler
   - add power off driver for i.mx6
   - add DT support for gpio-charger"

* tag 'for-v3.19' of git://git.infradead.org/battery-2.6:
  power: reset: adjust priority of simple syscon reboot driver
  power: ds2782_battery: Simplify the PM hooks
  power/reset: brcmstb: Register with kernel restart handler
  power/reset: hisi: Register with kernel restart handler
  power/reset: keystone: Register with kernel restart handler
  power/reset: axxia: Register with kernel restart handler
  power/reset: xgene: Register with kernel restart handler
  power/reset: xgene: Use mdelay instead of jiffies based timeout
  power/reset: xgene: Use local variable dev instead of pdev->dev
  power/reset: xgene: Drop devm_kfree
  power/reset: xgene: Return -ENOMEM if out of memory
  power/reset: vexpress: Register with kernel restart handler
  power: reset: imx-snvs-poweroff: add power off driver for i.mx6
  power: gpio-charger: add device tree support
  dt-bindings: document gpio-charger bindings
2014-12-15 17:36:45 -08:00
Linus Torvalds e6b5be2be4 Driver core patches for 3.19-rc1
Here's the set of driver core patches for 3.19-rc1.
 
 They are dominated by the removal of the .owner field in platform
 drivers.  They touch a lot of files, but they are "simple" changes, just
 removing a line in a structure.
 
 Other than that, a few minor driver core and debugfs changes.  There are
 some ath9k patches coming in through this tree that have been acked by
 the wireless maintainers as they relied on the debugfs changes.
 
 Everything has been in linux-next for a while.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iEYEABECAAYFAlSOD20ACgkQMUfUDdst+ylLPACg2QrW1oHhdTMT9WI8jihlHVRM
 53kAoLeteByQ3iVwWurwwseRPiWa8+MI
 =OVRS
 -----END PGP SIGNATURE-----

Merge tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core update from Greg KH:
 "Here's the set of driver core patches for 3.19-rc1.

  They are dominated by the removal of the .owner field in platform
  drivers.  They touch a lot of files, but they are "simple" changes,
  just removing a line in a structure.

  Other than that, a few minor driver core and debugfs changes.  There
  are some ath9k patches coming in through this tree that have been
  acked by the wireless maintainers as they relied on the debugfs
  changes.

  Everything has been in linux-next for a while"

* tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits)
  Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries"
  fs: debugfs: add forward declaration for struct device type
  firmware class: Deletion of an unnecessary check before the function call "vunmap"
  firmware loader: fix hung task warning dump
  devcoredump: provide a one-way disable function
  device: Add dev_<level>_once variants
  ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries
  ath: use seq_file api for ath9k debugfs files
  debugfs: add helper function to create device related seq_file
  drivers/base: cacheinfo: remove noisy error boot message
  Revert "core: platform: add warning if driver has no owner"
  drivers: base: support cpu cache information interface to userspace via sysfs
  drivers: base: add cpu_device_create to support per-cpu devices
  topology: replace custom attribute macros with standard DEVICE_ATTR*
  cpumask: factor out show_cpumap into separate helper function
  driver core: Fix unbalanced device reference in drivers_probe
  driver core: fix race with userland in device_add()
  sysfs/kernfs: make read requests on pre-alloc files use the buffer.
  sysfs/kernfs: allow attributes to request write buffer be pre-allocated.
  fs: sysfs: return EGBIG on write if offset is larger than file size
  ...
2014-12-14 16:10:09 -08:00
Linus Torvalds 6cd94d5e57 ARM: SoC platform changes for 3.19
New and updated SoC support, notable changes include:
 
 * bcm: brcmstb SMP support
 * bcm: initial iproc/cygnus support
 * exynos: Exynos4415 SoC support
 * exynos: PMU and suspend support for Exynos5420
 * exynos: PMU support for Exynos3250
 * exynos: pm related maintenance
 * imx: new LS1021A SoC support
 * imx: vybrid 610 global timer support
 * integrator: convert to using multiplatform configuration
 * mediatek: earlyprintk support for mt8127/mt8135
 * meson: meson8 soc and l2 cache controller support
 * mvebu: Armada 38x CPU hotplug support
 * mvebu: drop support for prerelease Armada 375 Z1 stepping
 * mvebu: extended suspend support, now works on Armada 370/XP
 * omap: hwmod related maintenance
 * omap: prcm cleanup
 * pxa: initial pxa27x DT handling
 * rockchip: SMP support for rk3288
 * rockchip: add cpu frequency scaling support
 * shmobile: r8a7740 power domain support
 * shmobile: various small restart, timer, pci apmu changes
 * sunxi: Allwinner A80 (sun9i) earlyprintk support
 * ux500: power domain support
 
 Overall, a significant chunk of changes, coming mostly from
 the usual suspects: omap, shmobile, samsung and mvebu, all of
 which already contain a lot of platform specific code in
 arch/arm.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iQIVAwUAVIcjyGCrR//JCVInAQJJCRAA1Tm+HZGiAiTvXEAcm/T9tIA08uqtawHt
 cqyEAUyrnE8QxE4EhUd2pTw4EunVusqKF5EsDxOzw7b3ukUdLAWZE7bqBOSIJLqn
 hrfsQQ8dXLbyC7T/CHPnBVeM+pn9LiIc9qzpZ0YToiMnHBBI4vKFQntBjd31yoRE
 hN08I6AmDjQolOzzlqR1fuM0uZaKiHIcytdauTt3Vfqgg7FTHcTy3u1kClHTR1Lp
 m/KuDothGpR5OKjSnUQz7EO5V3KJEnaKey8z2xM1a7DLLAvJ6r2+DUaDopv9Dbz1
 W/V3H7fi5tLvillVa8xmlmzqWZbPc1xw8MWqvHZSWIMRZqloAHpC1VWKn0ZuH4SW
 5Bj4ubSrpYjJxjKYfrxtjmuzru3A2jWBNTSP5A4nsny0C3AUsXkfRmRS0VNdegF8
 sUdQ1MF8vEMpQT3QPH88+ccFHeIgqbcayhKqLPf7r8q0kwlym5N7Y2amU2A/O6qz
 +324r+yzfSA70VgJZ5EhXxWVDOPB4Lc8EtoWnH6T/kjncIMwzEsbEbyB3X1OaREW
 pVn3PNo06VjHLYoiHX+8G99pOFR/JZvaQs6jGCXLs+Orjp5WfP+kafkWqcB5GAKU
 Pfd3AQsl6rKAITdu0XsTdPiICNS4CmBiWYPepQsTa3pQaNgB7fwZNQKelNRIdGc+
 dF1lnQ7CXLQ=
 =lFoH
 -----END PGP SIGNATURE-----

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

Pull ARM SoC platform changes from Arnd Bergmann:
 "New and updated SoC support, notable changes include:

   - bcm:
        brcmstb SMP support
        initial iproc/cygnus support
   - exynos:
        Exynos4415 SoC support
        PMU and suspend support for Exynos5420
        PMU support for Exynos3250
        pm related maintenance
   - imx:
        new LS1021A SoC support
        vybrid 610 global timer support
   - integrator:
        convert to using multiplatform configuration
   - mediatek:
        earlyprintk support for mt8127/mt8135
   - meson:
        meson8 soc and l2 cache controller support
   - mvebu:
        Armada 38x CPU hotplug support
        drop support for prerelease Armada 375 Z1 stepping
        extended suspend support, now works on Armada 370/XP
   - omap:
        hwmod related maintenance
        prcm cleanup
   - pxa:
        initial pxa27x DT handling
   - rockchip:
        SMP support for rk3288
        add cpu frequency scaling support
   - shmobile:
        r8a7740 power domain support
        various small restart, timer, pci apmu changes
   - sunxi:
        Allwinner A80 (sun9i) earlyprintk support
   - ux500:
        power domain support

  Overall, a significant chunk of changes, coming mostly from the usual
  suspects: omap, shmobile, samsung and mvebu, all of which already
  contain a lot of platform specific code in arch/arm"

* tag 'soc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (187 commits)
  ARM: mvebu: use the cpufreq-dt platform_data for independent clocks
  soc: integrator: Add terminating entry for integrator_cm_match
  ARM: mvebu: add SDRAM controller description for Armada XP
  ARM: mvebu: adjust mbus controller description on Armada 370/XP
  ARM: mvebu: add suspend/resume DT information for Armada XP GP
  ARM: mvebu: synchronize secondary CPU clocks on resume
  ARM: mvebu: make sure MMU is disabled in armada_370_xp_cpu_resume
  ARM: mvebu: Armada XP GP specific suspend/resume code
  ARM: mvebu: reserve the first 10 KB of each memory bank for suspend/resume
  ARM: mvebu: implement suspend/resume support for Armada XP
  clk: mvebu: add suspend/resume for gatable clocks
  bus: mvebu-mbus: provide a mechanism to save SDRAM window configuration
  bus: mvebu-mbus: suspend/resume support
  clocksource: time-armada-370-xp: add suspend/resume support
  irqchip: armada-370-xp: Add suspend/resume support
  ARM: add lolevel debug support for asm9260
  ARM: add mach-asm9260
  ARM: EXYNOS: use u8 for val[] in struct exynos_pmu_conf
  power: reset: imx-snvs-poweroff: add power off driver for i.mx6
  ARM: imx: temporarily remove CONFIG_SOC_FSL from LS1021A
  ...
2014-12-09 14:38:28 -08:00
Stefan Agner b81180b3fd power: reset: adjust priority of simple syscon reboot driver
Currently, all restart handler use the priority 128, including
watchdogs. Probably most SoC have a watchdog, and some of them
register it also as a restart handler. But if a SoC specifies
a dedicated reboot capability using this syscon driver, this is
usually the preferred reboot method. Hence, raise the priority
of this driver to 192.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
2014-12-03 20:38:30 +01:00
Robin Gong 3db47dc0ae power: reset: imx-snvs-poweroff: add power off driver for i.mx6
This driver register pm_power_off with snvs power off function. If
your boards NOT use PMIC_ON_REQ to turn on/off external pmic, or use
other pin to do, please disable the driver in dts, otherwise, your
pm_power_off maybe overwrote by this driver.

Signed-off-by: Robin Gong <b38343@freescale.com>
Acked-By: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2014-11-23 14:57:11 +08:00
Guenter Roeck 6136c41ae9 power/reset: brcmstb: Register with kernel restart handler
Register with kernel restart handler instead of setting arm_pm_restart directly.

Cc: Marc Carino <marc.ceeeee@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-11-17 03:07:10 +01:00