Commit Graph

104 Commits

Author SHA1 Message Date
Masahiro Yamada f109deb22e reset: make device_reset_optional() really optional
commit 1554bbd4ad upstream.

Commit bb475230b8 ("reset: make optional functions really optional")
converted *_get_optional* functions, but device_reset_optional() was
left behind.  Convert it in the same way.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-08 13:05:08 +01:00
Philipp Zabel ee6e7fba7f reset: add exported __reset_control_get, return NULL if optional
commit 62e24c5775 upstream.

Rename the internal __reset_control_get/put functions to
__reset_control_get/put_internal and add an exported
__reset_control_get equivalent to __of_reset_control_get
that takes a struct device parameter.
This avoids the confusing call to __of_reset_control_get in
the non-DT case and fixes the devm_reset_control_get_optional
function to return NULL if RESET_CONTROLLER is enabled but
dev->of_node == NULL.

Fixes: bb475230b8 ("reset: make optional functions really optional")
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Ramiro Oliveira <Ramiro.Oliveira@synopsys.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-08 13:05:08 +01:00
Heiner Kallweit d4b89ecc29 reset: core: fix reset_control_put
commit 4891486fb2 upstream.

Commit "reset: make optional functions really optional" missed to
adjust one check in reset_control_put, causing a NULL pointer
access for optional resets.

Fixes: bb475230b8 "reset: make optional functions really optional"
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-08 13:05:08 +01:00
Ramiro Oliveira ca58e3b2fc reset: make optional functions really optional
commit bb475230b8 upstream.

The *_get_optional_* functions weren't really optional so this patch
makes them really optional.

These *_get_optional_* functions will now return NULL instead of an error
if no matching reset phandle is found in the DT, and all the
reset_control_* functions now accept NULL rstc pointers.

Signed-off-by: Ramiro Oliveira <Ramiro.Oliveira@synopsys.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-08 13:05:08 +01:00
Jeremy Linton 5cb2faefc1 reset: hi6220: Set module license so that it can be loaded
[ Upstream commit 4497a224f7 ]

The hi6220_reset driver can be built as a standalone module
yet it cannot be loaded because it depends on GPL exported symbols.

Lets set the module license so that the module loads, and things like
the on-board kirin drm starts working.

Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com>
Reviewed-by: Xinliang Liu <xinliang.liu@linaro.org>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-10 07:42:47 -08:00
Jiancheng Xue bed7533196 reset: ti_syscon: fix a ti_syscon_reset_status issue
[ Upstream commit 5987b4bf51 ]

If STATUS_SET was not set, ti_syscon_reset_status would always return 0
no matter whether the status_bit was set or not.

Signed-off-by: Jiancheng Xue <xuejiancheng@hisilicon.com>
Fixes: cc7c2bb149 ("reset: add TI SYSCON based reset driver")
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-08 10:26:03 +02:00
Masahiro Yamada 19eb4a4722 reset: uniphier: rename MIO reset to SD reset for Pro5, PXs2, LD20 SoCs
I made a mistake as for naming for this block.  The MIO block is not
implemented for these 3 SoCs in the first place.  The current naming
will be a trouble if an SoC with both MIO and SD-ctrl blocks appear
in the future.

This driver has just been merged in the previous merge window.
Rename it before the release.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-10-22 18:31:42 +09:00
Philipp Zabel cddb480016 reset: hi6220: allow to compile test driver on other architectures
Also remove the RESET_CONTROLLER dependency, this Kconfig file is
included inside the menuconfig already.

Cc: Chen Feng <puck.chen@hisilicon.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-30 17:09:14 +02:00
Philipp Zabel 6f51b86007 reset: zynq: add driver Kconfig option
Visible only if COMPILE_TEST is enabled, this allows to include the
driver in build tests.

Cc: Moritz Fischer <moritz.fischer@ettus.com>
Cc: Sören Brinkmann <soren.brinkmann@xilinx.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-30 17:08:51 +02:00
Philipp Zabel 0ae084195b reset: sunxi: add driver Kconfig option
Visible only if COMPILE_TEST is enabled, this allows to include the
driver in build tests.

Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-30 09:38:46 +02:00
Philipp Zabel 7e0e901d41 reset: stm32: add driver Kconfig option
Visible only if COMPILE_TEST is enabled, this allows to include the
driver in build tests.

Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Gabriel Fernandez <gabriel.fernandez@st.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-30 09:38:45 +02:00
Philipp Zabel 5c91407ed3 reset: socfpga: add driver Kconfig option
Visible only if COMPILE_TEST is enabled, this allows to include the
driver in build tests.

Acked-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-30 09:38:44 +02:00
Philipp Zabel fab3f73098 reset: pistachio: add driver Kconfig option
Visible only if COMPILE_TEST is enabled, this allows to include the
driver in build tests.

Cc: Damien Horsley <Damien.Horsley@imgtec.com>
Acked-by: James Hartley <james.hartley@imgtec.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-30 09:38:10 +02:00
Philipp Zabel 44336c24a9 reset: meson: add driver Kconfig option
Visible only if COMPILE_TEST is enabled, this allows to include the
driver in build tests.

Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-25 13:27:44 +02:00
Philipp Zabel cd7f4b81cf reset: lpc18xx: add driver Kconfig option
Visible only if COMPILE_TEST is enabled, this allows to include the
driver in build tests.

Acked-by: Joachim Eastwood <manabian@gmail.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-25 13:27:43 +02:00
Philipp Zabel 70d467ea16 reset: berlin: add driver Kconfig option
Visible only if COMPILE_TEST is enabled, this allows to include the
driver in build tests.

Cc: Antoine Tenart <antoine.tenart@free-electrons.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-25 13:27:42 +02:00
Philipp Zabel e27b4a6e63 reset: ath79: add driver Kconfig option
Visible only if COMPILE_TEST is enabled, this allows to include the
driver in build tests.

Acked-by: Aban Bedel <albeu@free.fr>
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-25 13:27:35 +02:00
Philipp Zabel 9e9ba091aa reset: ath79: add missing include
The driver uses readl/writel, so it should include linux/io.h.

Acked-by: Aban Bedel <albeu@free.fr>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-25 13:27:23 +02:00
Philipp Zabel a3774e146a reset: warn on invalid input to reset_control_reset/assert/deassert/status
Instead of potentially crashing, dump a backtrace and return -EINVAL if
rstc is NULL or an error code.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-24 15:21:36 +02:00
Masahiro Yamada 54e991b566 reset: uniphier: add reset controller driver for UniPhier SoCs
This is the initial commit for UniPhier reset controller driver.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-24 15:21:35 +02:00
Maxime Coquelin b70b009b24 drivers: reset: Add STM32 reset driver
The STM32 MCUs family IPs can be reset by accessing some registers
from the RCC block.

The list of available reset lines is documented in the DT bindings.

Signed-off-by: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Signed-off-by: Gabriel Fernandez <gabriel.fernandez@st.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-08-24 15:21:28 +02:00
Philipp Zabel 6b37d3e956 reset: socfpga: no need to store modrst_offset
Since we can just add it to membase once, there is no need to store
modrst_offset separately, and to repeat the addition with every access.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>
2016-08-08 19:23:32 +02:00
Andrew F. Davis cc7c2bb149 reset: add TI SYSCON based reset driver
Add a reset-controller driver for performing reset management of
various devices present on the SoC, with the reset registers shared
between devices in a common register memory space. This driver uses
the syscon/regmap frameworks to actually implement the various reset
functionalities needed by the reset consumer devices.

Signed-off-by: Andrew F. Davis <afd@ti.com>
[s-anna@ti.com: add documentation, syscon name change]
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-06-29 23:39:10 +02:00
Xinliang Liu ab52b599c1 reset: hisilicon: Add hi6220 media subsystem reset support
Add hi6220 media subsystem reset controller.

Signed-off-by: Chen Feng <puck.chen@hisilicon.com>
Signed-off-by: Xia Qing <saberlily.xia@hisilicon.com>
Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-06-29 23:39:09 +02:00
Chen Feng 8768a26cea reset: hisilicon: Change to syscon register access
There are two reset controllers in hi6220 SoC:
The peripheral reset controller bits are part of sysctrl registers.
The media reset controller bits are part of mediactrl registers.

So change register access to syscon way.
And rename current reset controller to peripheral one.

Signed-off-by: Chen Feng <puck.chen@hisilicon.com>
Signed-off-by: Xia Qing <saberlily.xia@hisilicon.com>
Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-06-29 23:39:09 +02:00
Neil Armstrong c7224dc343 reset: Add support for the Amlogic Meson SoC Reset Controller
This patch adds the platform driver for the Amlogic Meson SoC Reset
Controller.

The Meson8b and GXBB SoCs are supported.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-06-01 08:21:10 +02:00
Neil Armstrong 42fa905bd9 reset: oxnas: Use devm register API and get rid of platform remove
Use the brand new devm_reset_controller_register() API to get rid of
the platform driver remove callback.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-05-30 09:37:47 +02:00
Masahiro Yamada 998cd4637f reset: fix Kconfig menu to include reset drivers in sub-menu
In "make menuconfig", reset drivers are currently lined up together
with the reset sub-system menu, like this:

    -*- Reset Controller Support  ----
    < > Hi6220 Reset Driver

(It also means, the menu "Reset Controller Support" is always empty.)

"Hi6220 Reset Driver" should go into the sub-menu of the
"Reset Controller Support".

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-05-30 09:37:47 +02:00
Masahiro Yamada da1fda2a23 reset: zynq: use devm_reset_controller_register()
Use devm_reset_controller_register() for the reset controller
registration and drop the .remove callback.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-05-30 09:37:47 +02:00
Masahiro Yamada dc22e08ef7 reset: socfpga: use devm_reset_controller_register()
Use devm_reset_controller_register() for the reset controller
registration and drop the .remove callback.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-05-30 09:37:47 +02:00
Masahiro Yamada 2f38a88c7c reset: sunxi: use devm_reset_controller_register()
Use devm_reset_controller_register() for the reset controller
registration and drop the .remove callback.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-05-30 09:37:47 +02:00
Masahiro Yamada 1b1447f493 reset: pistachio: use devm_reset_controller_register()
Use devm_reset_controller_register() for the reset controller
registration and drop the .remove callback.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-05-30 09:37:47 +02:00
Masahiro Yamada 56865f452a reset: ath79: use devm_reset_controller_register()
Use devm_reset_controller_register() for the reset controller
registration and remove the unregister call from the .remove callback.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-05-30 09:37:47 +02:00
Masahiro Yamada 8d5b5d5ce5 reset: add devm_reset_controller_register API
Add a device managed API for reset_controller_register().

This helps in reducing code in .remove callbacks and sometimes
dropping .remove callbacks entirely.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-05-30 09:37:47 +02:00
Neil Armstrong 6e667fac82 reset: Add Oxford Semiconductor Reset Controller driver
Add System reset controller driver for Oxford Semiconductor OXNAS SoC
Family.

CC: Ma Haijun <mahaijuns@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-04-01 16:31:09 +02:00
Joachim Eastwood 773fe72630 reset: lpc18xx: get rid of global variables for restart notifier
Moving the notifier_block into the drivers priv struct allows us
to retrive the priv struct with container_of and remove the
global variables.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-03-30 15:42:07 +02:00
Hans de Goede 0b52297f22 reset: Add support for shared reset controls
In some SoCs some hw-blocks share a reset control. Add support for this
setup by adding new:

reset_control_get_shared()
devm_reset_control_get_shared()
devm_reset_control_get_shared_by_index()

methods to get a reset_control. Note that this patch omits adding of_
variants, if these are needed later they can be easily added.

This patch also changes the behavior of the existing exclusive
reset_control_get() variants, if these are now called more then once
for the same reset_control they will return -EBUSY. To catch existing
drivers triggering this error (there should not be any) a WARN_ON(1)
is added in this path.

When a reset_control is shared, the behavior of reset_control_assert /
deassert is changed, for shared reset_controls these will work like the
clock-enable/disable and regulator-on/off functions. They will keep a
deassert_count, and only (re-)assert the reset after reset_control_assert
has been called as many times as reset_control_deassert was called.

Calling reset_control_assert without first calling reset_control_deassert
is not allowed on a shared reset control. Calling reset_control_reset is
also not allowed on a shared reset control.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-03-30 15:42:05 +02:00
Hans de Goede c15ddec2ca reset: Share struct reset_control between reset_control_get calls
Now that struct reset_control no longer stores the device pointer for
the device calling reset_control_get we can share a single struct
reset_control when multiple calls to reset_control_get are made for
the same reset line (same id / index).

This is a preparation patch for adding support for shared reset lines.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-03-30 15:42:03 +02:00
Hans de Goede 6c96f05c8b reset: Make [of_]reset_control_get[_foo] functions wrappers
With both the regular, _by_index and _optional variants we already have
quite a few variants of [of_]reset_control_get[_foo], the upcoming
addition of shared reset lines support makes this worse.

This commit changes all the variants into wrappers around common core
functions. For completeness sake this commit also adds a new
devm_get_reset_control_by_index wrapper.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-03-30 15:42:01 +02:00
Philipp Zabel f673ed4d5f reset: sti: Make reset_control_ops const
The syscfg_reset_ops structure is never modified. Make it const.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-02-10 10:53:38 +01:00
Philipp Zabel 356d108f87 reset: zynq: Make reset_control_ops const
The zynq_reset_ops structure is never modified. Make it const.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-02-10 10:53:37 +01:00
Philipp Zabel 387eb3f3d5 reset: socfpga: Make reset_control_ops const
The socfpga_reset_ops structure is never modified. Make it const.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-02-10 10:53:36 +01:00
Philipp Zabel 0e18e60e1b reset: hi6220: Make reset_control_ops const
The hi6220_reset_ops structure is never modified. Make it const.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-02-10 10:53:35 +01:00
Philipp Zabel d2f79f223f reset: ath79: Make reset_control_ops const
The ath79_reset_ops structure is never modified. Make it const.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Alban Bedel <albeu@free.fr>
2016-02-10 10:53:34 +01:00
Philipp Zabel 1a55cad19f reset: lpc18xx: Make reset_control_ops const
The lpc18xx_rgu_ops structure is never modified. Make it const.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Joachim Eastwood <manabian@gmail.com>
2016-02-08 17:19:57 +01:00
Philipp Zabel 01501d5730 reset: sunxi: Make reset_control_ops const
The sunxi_reset_ops structure is never modified. Make it const.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2016-02-08 17:03:48 +01:00
Philipp Zabel c0cc2609bc reset: img: Make reset_control_ops const
The pistachio_reset_ops structure is never modified. Make it const.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: James Hartley <james.hartley@imgtec.com>
2016-02-08 17:03:40 +01:00
Philipp Zabel b7a9007565 reset: berlin: Make reset_control_ops const
The berlin_reset_ops structure is never modified. Make it const.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Antoine Tenart <antoine.tenart@free-electrons.com>
2016-02-08 16:11:25 +01:00
Philipp Zabel 27ca5aaa36 reset: berlin: drop DT cell size check
Now that the DT cell size check has been moved to the core,
there is no need to check again.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-02-05 16:42:31 +01:00
Damien Horsley 8a56736a2f reset: img: Add Pistachio reset controller driver
Add reset controller driver for Pistachio SoC

Signed-off-by: Damien Horsley <Damien.Horsley@imgtec.com>
Signed-off-by: James Hartley <james.hartley@imgtec.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2016-02-05 16:41:20 +01:00