aboutsummaryrefslogtreecommitdiff
path: root/drivers/reset/core.c
AgeCommit message (Collapse)AuthorFilesLines
2020-09-23reset: Fix and extend kerneldocKrzysztof Kozlowski1-1/+2
Fix W=1 compile warnings (invalid kerneldoc): drivers/reset/core.c:50: warning: Function parameter or member 'array' not described in 'reset_control' drivers/reset/core.c:50: warning: Function parameter or member 'deassert_count' not described in 'reset_control' Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2020-01-02reset: Align logic and flow in managed helpersGeert Uytterhoeven1-16/+17
__devm_reset_control_get() and devm_reset_control_array_get() are very similar, but they do not look similar, due to inverted logic. Make them more similar, following the "bail out early" paradigm. Adjust the logic and flow in devm_reset_controller_register() to match the two other functions. Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2019-12-10reset: Do not register resource data for missing resetsGeert Uytterhoeven1-2/+2
When an optional reset is not present, __devm_reset_control_get() and devm_reset_control_array_get() still register resource data to release the non-existing reset on cleanup, which is futile. Fix this by skipping NULL reset control pointers. Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2019-12-10reset: Fix {of,devm}_reset_control_array_get kerneldoc return typesGeert Uytterhoeven1-4/+2
of_reset_control_array_get() and devm_reset_control_array_get() return struct reset_control pointers, not internal struct reset_control_array pointers, just like all other reset control API calls. Correct the kerneldoc to match the code. Fixes: 17c82e206d2a3cd8 ("reset: Add APIs to manage array of resets") Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2019-12-05Merge tag 'armsoc-drivers' of ↵Linus Torvalds1-4/+4
git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc Pull ARM SoC driver updates from Olof Johansson: "Various driver updates for platforms: - A larger set of work on Tegra 2/3 around memory controller and regulator features, some fuse cleanups, etc.. - MMP platform drivers, in particular for USB PHY, and other smaller additions. - Samsung Exynos 5422 driver for DMC (dynamic memory configuration), and ASV (adaptive voltage), allowing the platform to run at more optimal operating points. - Misc refactorings and support for RZ/G2N and R8A774B1 from Renesas - Clock/reset control driver for TI/OMAP - Meson-A1 reset controller support - Qualcomm sdm845 and sda845 SoC IDs for socinfo" * tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (150 commits) firmware: arm_scmi: Fix doorbell ring logic for !CONFIG_64BIT soc: fsl: add RCPM driver dt-bindings: fsl: rcpm: Add 'little-endian' and update Chassis definition memory: tegra: Consolidate registers definition into common header memory: tegra: Ensure timing control debug features are disabled memory: tegra: Introduce Tegra30 EMC driver memory: tegra: Do not handle error from wait_for_completion_timeout() memory: tegra: Increase handshake timeout on Tegra20 memory: tegra: Print a brief info message about EMC timings memory: tegra: Pre-configure debug register on Tegra20 memory: tegra: Include io.h instead of iopoll.h memory: tegra: Adapt for Tegra20 clock driver changes memory: tegra: Don't set EMC rate to maximum on probe for Tegra20 memory: tegra: Add gr2d and gr3d to DRM IOMMU group memory: tegra: Set DMA mask based on supported address bits soc: at91: Add Atmel SFR SN (Serial Number) support memory: atmel-ebi: switch to SPDX license identifiers memory: atmel-ebi: move NUM_CS definition inside EBI driver soc: mediatek: Refactor bus protection control soc: mediatek: Refactor sram control ...
2019-10-24reset: improve of_xlate documentationPhilipp Zabel1-2/+4
Mention of_reset_simple_xlate as the default if of_xlate is not set. Signed-off-by: Philipp Zabel <[email protected]>
2019-10-24reset: fix of_reset_control_get_count kerneldoc commentPhilipp Zabel1-1/+2
Add a newline and remove a superfluous kerneldoc marker before the of_reset_control_get_count kerneldoc comment, to fix documentation build warnings: ./drivers/reset/core.c:832: warning: Incorrect use of kernel-doc format: * of_reset_control_get_count - Count number of resets available with a device ./drivers/reset/core.c:840: warning: Function parameter or member 'node' not described in 'of_reset_control_get_count' Fixes: 17c82e206d2a ("reset: Add APIs to manage array of resets") Signed-off-by: Philipp Zabel <[email protected]>
2019-10-24reset: fix of_reset_simple_xlate kerneldoc commentPhilipp Zabel1-1/+0
The flags parameter never made it into the API, but was erroneously included in the kerneldoc comment. Remove it to fix a documentation build warning: ./drivers/reset/core.c:86: warning: Excess function parameter 'flags' description in 'of_reset_simple_xlate' Fixes: 61fc41317666 ("reset: Add reset controller API") Signed-off-by: Philipp Zabel <[email protected]>
2019-10-22reset: Fix memory leak in reset_control_array_put()Kishon Vijay Abraham I1-0/+1
Memory allocated for 'struct reset_control_array' in of_reset_control_array_get() is never freed in reset_control_array_put() resulting in kmemleak showing the following backtrace. backtrace: [<00000000c5f17595>] __kmalloc+0x1b0/0x2b0 [<00000000bd499e13>] of_reset_control_array_get+0xa4/0x180 [<000000004cc02754>] 0xffff800008c669e4 [<0000000050a83b24>] platform_drv_probe+0x50/0xa0 [<00000000d3a0b0bc>] really_probe+0x108/0x348 [<000000005aa458ac>] driver_probe_device+0x58/0x100 [<000000008853626c>] device_driver_attach+0x6c/0x90 [<0000000085308d19>] __driver_attach+0x84/0xc8 [<00000000080d35f2>] bus_for_each_dev+0x74/0xc8 [<00000000dd7f015b>] driver_attach+0x20/0x28 [<00000000923ba6e6>] bus_add_driver+0x148/0x1f0 [<0000000061473b66>] driver_register+0x60/0x110 [<00000000c5bec167>] __platform_driver_register+0x40/0x48 [<000000007c764b4f>] 0xffff800008c6c020 [<0000000047ec2e8c>] do_one_initcall+0x5c/0x1b0 [<0000000093d4b50d>] do_init_module+0x54/0x1d0 Fixes: 17c82e206d2a ("reset: Add APIs to manage array of resets") Signed-off-by: Kishon Vijay Abraham I <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2019-10-03reset: Remove copy'n'paste redundancy in the commentsAndy Shevchenko1-2/+0
It seems the commit bb475230b8e5 ("reset: make optional functions really optional") brought couple of redundant lines in the comments. Drop them here. Cc: Ramiro Oliveira <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2019-07-04Merge tag 'reset-fixes-for-v5.2' of git://git.pengutronix.de/git/pza/linux ↵Olof Johansson1-3/+0
into arm/drivers Reset controller fix for v5.2 This tag removes a redundant device pointer NULL check from __reset_control_get_from_lookup to fix a static code checker warning. * tag 'reset-fixes-for-v5.2' of git://git.pengutronix.de/git/pza/linux: reset: remove redundant null check on pointer dev Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Olof Johansson <[email protected]>
2019-07-04reset: remove redundant null check on pointer devColin Ian King1-3/+0
Pointer dev is being dereferenced when passed to the inlined functon dev_name, however, dev is later being null checked so at first this seems like a potential null pointer dereference. In fact, _reset_control_get_from_lookup is only ever called from __reset_control_get, right after checking dev->of_node hence dev can never be null. Clean this up by removing the redundant null check. Thanks to Philipp Zabel for spotting that dev can never be null. Addresses-Coverity: ("Dereference before null check") Fixes: 6691dffab0ab ("reset: add support for non-DT systems") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152Thomas Gleixner1-5/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 3029 file(s). Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Allison Randal <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
2019-03-20reset: Add acquire/release support for arraysThierry Reding1-1/+35
Add implementations that apply acquire and release operations to all reset controls part of a reset control array. Signed-off-by: Thierry Reding <[email protected]> Reviewed-by: Philipp Zabel <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2019-03-20reset: Add acquired flag to of_reset_control_array_get()Thierry Reding1-3/+6
In order to be able to request an array of reset controls in acquired or released mode, add the acquired flag to of_reset_control_array_get() and pass the flag to subsequent calls of __of_reset_control_get(). Signed-off-by: Thierry Reding <[email protected]> Acked-by: Felipe Balbi <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2019-03-20reset: add acquired/released state for exclusive reset controlsPhilipp Zabel1-12/+127
There are cases where a driver needs explicit control over a reset line that is exclusively conneted to its device, but this control has to be temporarily handed over to the power domain controller to handle reset requirements during power transitions. Allow multiple exclusive reset controls to be requested in 'released' state for the same physical reset line, only one of which can be acquired at the same time. Signed-off-by: Philipp Zabel <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
2019-01-07reset: fix null pointer dereference on dev by dev_nameColin Ian King1-1/+2
The call to dev_name will dereference dev, however, dev is later being null checked, so there is a possibility of a null pointer dereference on dev by the call to dev_name. Fix this by null checking dev first before the call to dev_name Detected by CoverityScan, CID#1475475 ("Dereference before null check") Fixes: 2a6cb2b1d83b ("reset: Add reset_control_get_count()") Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2019-01-07reset: Add reset_control_get_count()Geert Uytterhoeven1-0/+41
Currently the reset core has internal support for counting the number of resets for a device described in DT. Generalize this to devices using lookup resets, and export it for public use. This will be used by generic drivers that need to be sure a device is controlled by a single, dedicated reset line (e.g. vfio-platform). Signed-off-by: Geert Uytterhoeven <[email protected]> [[email protected]: fixed a typo in reset_control_get_count comment] Signed-off-by: Philipp Zabel <[email protected]>
2018-10-08reset: Fix potential use-after-free in __of_reset_control_get()Geert Uytterhoeven1-7/+8
Calling of_node_put() decreases the reference count of a device tree object, and may free some data. However, the of_phandle_args structure embedding it is passed to reset_controller_dev.of_xlate() after that, so it may still be accessed. Move the call to of_node_put() down to fix this. Signed-off-by: Geert Uytterhoeven <[email protected]> [[email protected]: moved of_node_put after mutex_unlock] Signed-off-by: Philipp Zabel <[email protected]>
2018-06-06treewide: Use struct_size() for kmalloc()-familyKees Cook1-2/+1
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct foo { int stuff; void *entry[]; }; instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL); Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL); This patch makes the changes for kmalloc()-family (and kvmalloc()-family) uses. It was done via automatic conversion with manual review for the "CHECKME" non-standard cases noted below, using the following Coccinelle script: // pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len * // sizeof *pkey_cache->table, GFP_KERNEL); @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; identifier VAR, ELEMENT; expression COUNT; @@ - alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP) + alloc(struct_size(VAR, ELEMENT, COUNT), GFP) // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL); @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; identifier VAR, ELEMENT; expression COUNT; @@ - alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP) + alloc(struct_size(VAR, ELEMENT, COUNT), GFP) // Same pattern, but can't trivially locate the trailing element name, // or variable name. @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; expression SOMETHING, COUNT, ELEMENT; @@ - alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP) + alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP) Signed-off-by: Kees Cook <[email protected]>
2018-03-27reset: modify the way reset lookup works for board filesBartosz Golaszewski1-7/+31
Commit 7af1bb19f1d7 ("reset: add support for non-DT systems") introduced reset control lookup mechanism for boards that still use board files. The routine used to register lookup entries takes the corresponding reset_controlled_dev structure as argument. It's been determined however that for the first user of this new interface - davinci psc driver - it will be easier to register the lookup entries using the reset controller device name. This patch changes the way lookup entries are added. Signed-off-by: Bartosz Golaszewski <[email protected]> [[email protected]: added missing ERR_PTR] Signed-off-by: Philipp Zabel <[email protected]>
2018-03-27reset: add support for non-DT systemsBartosz Golaszewski1-1/+71
The reset framework only supports device-tree. There are some platforms however, which need to use it even in legacy, board-file based mode. An example of such architecture is the DaVinci family of SoCs which supports both device tree and legacy boot modes and we don't want to introduce any regressions. We're currently working on converting the platform from its hand-crafted clock API to using the common clock framework. Part of the overhaul will be representing the chip's power sleep controller's reset lines using the reset framework. This changeset extends the core reset code with a new reset lookup entry structure. It contains data allowing the reset core to associate reset lines with devices by comparing the dev_id and con_id strings. It also provides a function allowing drivers to register lookup entries with the framework. The new lookup function is only called as a fallback in case the of_node field is NULL and doesn't change anything for current users. Tested with a dummy reset driver with several lookup entries. An example lookup table registration from a driver can be found below: static struct reset_control_lookup foobar_reset_lookup[] = { RESET_LOOKUP("foo.0", "foo", 15), RESET_LOOKUP("bar.0", NULL, 5), }; foobar_probe() { ... reset_controller_add_lookup(&rcdev, foobar_reset_lookup, ARRAY_SIZE(foobar_reset_lookup)); ... } Cc: Sekhar Nori <[email protected]> Cc: Kevin Hilman <[email protected]> Cc: David Lechner <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2017-11-27reset: make device_reset_optional() really optionalMasahiro Yamada1-4/+5
Commit bb475230b8e5 ("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 <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2017-07-19reset: make (de)assert report success for self-deasserting reset driversPhilipp Zabel1-6/+25
By now there are drivers using shared reset controls and (de)assert calls on platforms with self-deasserting reset lines and thus reset drivers that do not implement .assert() and .deassert(). As long as the initial state of the reset line is deasserted, there is no reason for a reset_control_assert call to return an error for shared reset controls, or for a reset_control_deassert call to return an error for either shared or exclusive reset controls: after a call to reset_control_deassert the reset line is guaranteed to be deasserted, and after a call to reset_control_assert it is valid for the reset line to stay deasserted for shared reset controls. Signed-off-by: Philipp Zabel <[email protected]> Reviewed-by: Linus Walleij <[email protected]>
2017-07-19reset: Add APIs to manage array of resetsVivek Gautam1-1/+210
Many devices may want to request a bunch of resets and control them. So it's better to manage them as an array. Add APIs to _get() an array of reset_control, reusing the _assert(), _deassert(), and _reset() APIs for single reset controls. Since reset controls already may control multiple reset lines with a single hardware bit, from the user perspective, reset control arrays are not at all different from single reset controls. Note that these APIs don't guarantee that the reset lines managed in the array are handled in any particular order. Cc: Felipe Balbi <[email protected]> Cc: Jon Hunter <[email protected]> Signed-off-by: Vivek Gautam <[email protected]> [[email protected]: changed API to hide reset control arrays behind struct reset_control] Signed-off-by: Philipp Zabel <[email protected]>
2017-06-06reset: use kref for reference countingPhilipp Zabel1-8/+15
Use kref for reference counting and enjoy the advantages of refcount_t. Signed-off-by: Philipp Zabel <[email protected]>
2017-04-04reset: add exported __reset_control_get, return NULL if optionalPhilipp Zabel1-6/+16
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: bb475230b8e5 ("reset: make optional functions really optional") Reported-by: Andy Shevchenko <[email protected]> Tested-by: Andy Shevchenko <[email protected]> Cc: Ramiro Oliveira <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2017-02-23Merge tag 'armsoc-drivers' of ↵Linus Torvalds1-13/+42
git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc Pull ARM SoC driver updates from Arnd Bergmann: "Driver updates for ARM SoCs. A handful of driver changes this time around. The larger changes are: - Reset drivers for hi3660 and zx2967 - AHCI driver for Davinci, acked by Tejun and brought in here due to platform dependencies - Cleanups of atmel-ebi (External Bus Interface) - Tweaks for Rockchip GRF (General Register File) usage (kitchensink misc register range on the SoCs) - PM domains changes for support of two new ZTE SoCs (zx296718 and zx2967)" * tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (53 commits) soc: samsung: pmu: Add register defines for pad retention control reset: make zx2967 explicitly non-modular reset: core: fix reset_control_put soc: samsung: pm_domains: Read domain name from the new label property soc: samsung: pm_domains: Remove message about failed memory allocation soc: samsung: pm_domains: Remove unused name field soc: samsung: pm_domains: Use full names in subdomains registration log sata: ahci-da850: un-hardcode the MPY bits sata: ahci-da850: add a workaround for controller instability sata: ahci: export ahci_do_hardreset() locally sata: ahci-da850: implement a workaround for the softreset quirk sata: ahci-da850: add device tree match table sata: ahci-da850: get the sata clock using a connection id soc: samsung: pmu: Remove duplicated define for ARM_L2_OPTION register memory: atmel-ebi: Enable the SMC clock if specified soc: samsung: pmu: Remove unused and duplicated defines memory: atmel-ebi: Properly handle multiple reference to the same CS memory: atmel-ebi: Fix the test to enable generic SMC logic soc: samsung: pm_domains: Add new Exynos5433 compatible soc: samsung: pmu: Add dummy support for Exynos5433 SoC ...
2017-02-17reset: fix shared reset triggered_count decrement on errorJerome Brunet1-1/+1
For a shared reset, when the reset is successful, the triggered_count is incremented when trying to call the reset callback, so that another device sharing the same reset line won't trigger it again. If the reset has not been triggered successfully, the trigger_count should be decremented. The code does the opposite, and decrements the trigger_count on success. As a consequence, another device sharing the reset will be able to trigger it again. Fixed be removing negation in from of the error code of the reset function. Fixes: 7da33a37b48f ("reset: allow using reset_control_reset with shared reset") Signed-off-by: Jerome Brunet <[email protected]> Acked-by: Martin Blumenstingl <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2017-02-01reset: core: fix reset_control_putHeiner Kallweit1-1/+1
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: bb475230b8e5 "reset: make optional functions really optional" Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2017-01-20reset: make optional functions really optionalRamiro Oliveira1-10/+39
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 <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2017-01-20reset: Change shared flag from int to boolRamiro Oliveira1-4/+4
Since the new parameter being added is going to be a bool this patch changes the shared flag from int to bool to match the new parameter. Signed-off-by: Ramiro Oliveira <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2016-11-14reset: allow using reset_control_reset with shared resetMartin Blumenstingl1-6/+37
Some SoCs (for example Amlogic GXBB) implement a reset controller which only supports a reset pulse (triggered via reset_control_reset). At the same time multiple devices (in case of the Amlogic GXBB SoC both USB PHYs) are sharing the same reset line. This patch allows using reset_control_reset also for shared resets. There are limitations though: reset_control_reset can only be used if reset_control_assert was not used yet. reset_control_assert can only be used if reset_control_reset was not used yet. For shared resets the reset is only triggered once for the lifetime of the reset_control instance (the reset can be triggered again if all consumers of that specific reset_control are gone, as the reset framework will free the reset_control instance in that case). Signed-off-by: Martin Blumenstingl <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2016-08-24reset: warn on invalid input to reset_control_reset/assert/deassert/statusPhilipp Zabel1-1/+11
Instead of potentially crashing, dump a backtrace and return -EINVAL if rstc is NULL or an error code. Signed-off-by: Philipp Zabel <[email protected]>
2016-05-30reset: add devm_reset_controller_register APIMasahiro Yamada1-0/+37
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 <[email protected]> Acked-by: Laxman Dewangan <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2016-03-30reset: Add support for shared reset controlsHans de Goede1-11/+48
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 <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2016-03-30reset: Share struct reset_control between reset_control_get callsHans de Goede1-21/+63
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 <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2016-03-30reset: Make [of_]reset_control_get[_foo] functions wrappersHans de Goede1-67/+17
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 <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2016-01-25reset: Move DT cell size check to the coreMaxime Ripard1-3/+5
The core currently doesn't check that the DT cell size matches what the driver declares, which means that every xlate function needs to duplicate that check. Make sure that of_reset_control_get checks for this to avoid duplication and errors. Signed-off-by: Maxime Ripard <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2016-01-25reset: remove unnecessary local variable initialization from ↵Philipp Zabel1-1/+1
of_reset_control_get_by_index There is no need to initialize rstc, as it is unconditionally assigned the return value of a kzalloc call before use. Signed-off-by: Philipp Zabel <[email protected]>
2015-11-18reset: remove unused device pointer from struct reset_controlPhilipp Zabel1-8/+1
Commit 0c5b2b915a58 ("reset: Mark function as static and remove unused function in core.c") removed the only user of the device pointer in struct reset_control. As it is now unused, remove it. Signed-off-by: Philipp Zabel <[email protected]>
2015-11-16reset: use ENOTSUPP instead of ENOSYSPhilipp Zabel1-4/+4
ENOSYS is reserved to report invalid syscalls to userspace. Consistently return ENOTSUPP to indicate that the driver doesn't support the functionality or the reset framework is not enabled at all. Signed-off-by: Philipp Zabel <[email protected]>
2015-11-16reset: Fix of_reset_control_get() for consistent return valuesAlban Bedel1-1/+4
When of_reset_control_get() is called without connection ID it returns -ENOENT when the 'resets' property doesn't exists or is an empty entry. However when a connection ID is given it returns -EINVAL when the 'resets' property doesn't exists or the requested name can't be found. This is because the error code returned by of_property_match_string() is just passed down as an index to of_parse_phandle_with_args(), which then returns -EINVAL. To get a consistent return value with both code paths we must return -ENOENT when of_property_match_string() fails. Signed-off-by: Alban Bedel <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2015-11-16reset: add of_reset_control_get_by_index()Vince Hsu1-11/+29
Add of_reset_control_get_by_index() to allow the drivers to get reset device without knowing its name. Signed-off-by: Vince Hsu <[email protected]> [[email protected]: Updated stub function to return -ENOTSUPP instead of -ENOSYS which should only be used for system calls.] Signed-off-by: Jon Hunter <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2014-10-20reset: add reset_control_status helper functionDinh Nguyen1-0/+15
There are cases where a system will want to read a reset status bit before doing any other toggling. Add a reset_control_status helper function to the reset controller API. Signed-off-by: Dinh Nguyen <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2014-02-03reset: Add of_reset_control_getMaxime Ripard1-9/+30
In some cases, you might need to deassert from reset an hardware block that doesn't associated to a struct device (CPUs, timers, etc.). Add a small helper to retrieve the reset controller from the device tree without the need to pass a struct device. Signed-off-by: Maxime Ripard <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2014-02-03reset: Mark function as static and remove unused function in core.cRashika Kheria1-29/+1
Mark function of_reset_simple_xlate() as static in core.c because it is not used outside this file. Also, remove functions devm_reset_control_put() and devm_reset_control_match() because they are unused. This eliminates the following warnings in core.c: drivers/reset/core.c:46:5: warning: no previous prototype for ‘of_reset_simple_xlate’ [-Wmissing-prototypes] drivers/reset/core.c:262:6: warning: no previous prototype for ‘devm_reset_control_put’ [-Wmissing-prototypes] Signed-off-by: Rashika Kheria <[email protected]> Reviewed-by: Josh Triplett <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2014-02-03reset: allow drivers to request probe deferralPhilipp Zabel1-1/+1
If the requested reset controller is not yet available, have reset_control_get and device_reset return -EPROBE_DEFER so the driver can decide to request probe deferral. Signed-off-by: Philipp Zabel <[email protected]> Acked-by: Shawn Guo <[email protected]> Reviewed-by: Stephen Warren <[email protected]>
2013-04-12reset: NULL deref on allocation failureDan Carpenter1-1/+1
"rstc" is NULL here and we should use "rcdev" instead of "rstc->rcdev". Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Philipp Zabel <[email protected]>
2013-04-12reset: Add reset controller APIPhilipp Zabel1-0/+297
This adds a simple API for devices to request being reset by separate reset controller hardware and implements the reset signal device tree binding. Signed-off-by: Philipp Zabel <[email protected]> Reviewed-by: Stephen Warren <[email protected]> Reviewed-by: Shawn Guo <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Reviewed-by: Pavel Machek <[email protected]>