summaryrefslogtreecommitdiff
path: root/drivers/power/reset/at91-reset.c
AgeCommit message (Collapse)AuthorFilesLines
2023-11-16power: reset: at91-reset: Convert to platform remove callback returning voidUwe Kleine-König1-4/+2
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev> Link: https://lore.kernel.org/r/20231105094712.3706799-3-u.kleine-koenig@pengutronix.de Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-11-16power: reset: at91-reset: Stop using module_platform_driver_probe()Uwe Kleine-König1-4/+5
On today's platforms the benefit of platform_driver_probe() isn't that relevant any more. It allows to drop some code after booting (or module loading) for .probe() and discard the .remove() function completely if the driver is built-in. This typically saves a few 100k. The downside of platform_driver_probe() is that the driver cannot be bound and unbound at runtime which is ancient and so slightly complicates testing. There are also thoughts to deprecate platform_driver_probe() because it adds some complexity in the driver core for little gain. Also many drivers don't use it correctly. This driver for example misses to mark the driver struct with __ref which is needed to suppress a (W=1) modpost warning. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev> Link: https://lore.kernel.org/r/20231104211501.3676352-18-u.kleine-koenig@pengutronix.de Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-07-20power: reset: at91-reset: add sysfs interface to the power on reasonKamel Bouhara1-10/+27
Introduce a list of generic reset sources and use them to export the power on reason through sysfs. Update the ABI documentation to describe this new interface. Signed-off-by: Kamel Bouhara <kamel.bouhara@bootlin.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> [Miquel Raynal: Follow-up on Kamel's work, 4 years later] Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2023-06-20power: reset: at91-reset: change the power on reason prototypeMiquel Raynal1-5/+4
It is quite uncommon to use a driver helper with parameters like *pdev and __iomem *base. It is much cleaner and close to today's standards to provide the per-device driver structure and then access its internals. Let's do this with the helper which returns the power on reason. While we change the parameters, we can as well rename the function from at91_reset_status() to at91_reset_reason() to be more accurate with what the helper actually does, and finally because we don't really need the pdev argument in this helper besides for printing the reset reason, we can move the dev_info() call into the probe. All these modifications prepare the introduction of a sysfs entry to access this information. This way the diff will be much smaller. Thus, there is no intended functional change. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-06-17power: reset: at91-reset: add support for SAMA7G5Claudiu Beznea1-0/+13
Add support for SAMA7G5 including reset_controller_dev support for 3 lines (which are USB PHYs). Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-06-17power: reset: at91-reset: add reset_controller_dev supportClaudiu Beznea1-4/+102
SAMA7G5 reset controller has 5 extra lines that goes to different devices (3 lines to USB PHYs, 1 line to DDR controller, 1 line to DDR PHY controller). These reset lines could be requested by different controller drivers (e.g. USB PHY driver) and these controllers' drivers could assert/deassert these lines when necessary. Thus add support for reset_controller_dev which brings this functionality. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-06-17power: reset: at91-reset: add at91_reset_dataClaudiu Beznea1-11/+34
Add struct at91_reset_data to keep per platform related information. This is a prerequisite for adding reset_controller_dev support. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-06-17power: reset: at91-reset: document structures and enumsClaudiu Beznea1-0/+20
Document structures and enums. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-10-02power: reset: at91-reset: check properly the return value of devm_of_iomapClaudiu Beznea1-2/+2
devm_of_iomap() returns error code or valid pointer. Check its return value with IS_ERR(). Fixes: bd3127733f2c ("power: reset: at91-reset: use devm_of_iomap") Reported-by: Cristian Birsan <cristian.birsan@microchip.com> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2021-04-02power: reset: at91-reset: use devm_of_iomapClaudiu Beznea1-2/+2
Use devm_of_iomap() to map resources. This will avoid the necessity to track the mapped resources and free them on failure path or on remove. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Suggested-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: handle nrst async for sam9x60Claudiu.Beznea@microchip.com1-0/+8
Handle NRST asynchronously for SAM9X60 to avoid problem with fast drop of VDDCORE on shutdown operations in the first 100 us after CPU is shutdown. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: get rid of at91_reset_dataClaudiu.Beznea@microchip.com1-28/+9
After refactoring struct at91_reset_data and struct at91_reset_data at91sam9260_reset_data are not needed anymore. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: keep only one reset functionClaudiu.Beznea@microchip.com1-49/+3
Keep only one reset function. With this, notifier_call member of struct at91_reset_data could be removed. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: make at91sam9g45_restart() genericClaudiu.Beznea@microchip.com1-15/+6
Make at91sam9g45_restart() generic. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: introduce ramc_lpr to struct at91_resetClaudiu.Beznea@microchip.com1-8/+18
Introduce ramc_lpr to struct at91_reset. This will lead to the unification of at91sam9260_restart() and at91sam9g45_restart(). Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: use r4 as tmp argumentClaudiu.Beznea@microchip.com1-3/+3
Use r4 as temporary register. On ARM r0-r3 should be used to hold function arguments. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: introduce args member in at91_reset_dataClaudiu.Beznea@microchip.com1-16/+11
Introduce args member in struct at91_reset_data. It stores the value that needs to be written in mode register so that the reboot actions to happen. With these changes samx7_restart() could be removed. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: introduce struct at91_reset_dataClaudiu.Beznea@microchip.com1-6/+44
Introduce struct at91_reset_data to be able to provide per SoC data. At the moment this being only notifier callback. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: devm_kzalloc() for at91_reset data structureClaudiu.Beznea@microchip.com1-2/+13
Allocate at91_reset data on probe and set it as platform data. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: pass rstc base address to at91_reset_status()Claudiu.Beznea@microchip.com1-3/+4
Add new argument to at91_reset_status() that is the pointer to reset controller base address. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: convert reset in pointer to struct at91_resetClaudiu.Beznea@microchip.com1-23/+27
Convert reset in pointer to struct at91_reset. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: add notifier block to struct at91_resetClaudiu.Beznea@microchip.com1-7/+5
Add struct notifier_block to struct at91_reset. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: add sclk to struct at91_resetClaudiu.Beznea@microchip.com1-8/+7
Add sclk to struct at91_reset. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: add ramc_base[] to struct at91_resetClaudiu.Beznea@microchip.com1-6/+6
Add ramc_base[] to struct at91_reset. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2020-03-08power: reset: at91-reset: introduce struct at91_resetClaudiu.Beznea@microchip.com1-9/+17
Introduce struct at91_reset intended to keep all the at91 reset controller data. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-10-20power: reset: at91: fix __le32 cast in reset codeBen Dooks (Codethink)1-4/+2
The writel() takes standard integers, not __le32 so fix the following sparse warnings by removing the cpu_to_le32() calls. drivers/power/reset/at91-reset.c:134:9: warning: cast from restricted __le32 drivers/power/reset/at91-reset.c:143:9: warning: cast from restricted __le32 This has made no code changes, the md5sums pre and post applying this patch are the same. The at91 should be natively little endian anyway. Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-02-20power: reset: at91-reset: add support for sam9x60 SoCNicolas Ferre1-0/+13
Add support for additional reset causes and the proper compatibility string for sam9x60 SoC. The restart function is the same as the samx7. Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com> Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-03-19power: reset: at91-reset: Switch from the pr_*() to the dev_*() logging ↵Ladislav Michl1-2/+2
functions Use dev_info() instead of pr_info(). Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2017-01-18power: reset: at91-reset: remove leftover platform_device_idAlexandre Belloni1-8/+0
commit eacd8d09db7f ("power/reset: at91-reset: remove useless at91_reset_platform_probe()") removed non DT probe support but forgot to remove the now useless id_table. Do that now. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2017-01-18power: reset: at91-reset: add samx7 supportSzemző András1-0/+10
Add samx7 support. It is lacking a few bits and needs a new reset function. Signed-off-by: Szemző András <sza@esh.hu> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2016-10-19power: reset: at91-reset: Fix module autoloadJavier Martinez Canillas1-0/+2
If the driver is built as a module, autoload won't work because the module alias information is not filled. So user-space can't match the registered device with the corresponding module. Export the module alias information using the MODULE_DEVICE_TABLE() macro. Before this patch: $ modinfo drivers/power/reset/at91-reset.ko | grep alias $ After this patch: $ modinfo drivers/power/reset/at91-reset.ko | grep alias alias: of:N*T*Catmel,sama5d3-rstcC* alias: of:N*T*Catmel,sama5d3-rstc alias: of:N*T*Catmel,at91sam9g45-rstcC* alias: of:N*T*Catmel,at91sam9g45-rstc alias: of:N*T*Catmel,at91sam9260-rstcC* alias: of:N*T*Catmel,at91sam9260-rstc alias: platform:at91-sam9g45-reset alias: platform:at91-sam9260-reset Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-12-05power/reset: at91-reset: add missing of_node_putJulia Lawall1-0/+1
for_each_matching_node performs an of_node_get on each iteration, so a break out of the loop requires an of_node_put. A simplified version of the semantic patch that fixes this problem is as follows (http://coccinelle.lip6.fr): // <smpl> @@ expression e,e1; local idexpression np; @@ for_each_matching_node(np, e1) { ... when != of_node_put(np) when != e = np ( return np; | + of_node_put(np); ? return ...; ) ... } // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-22power: reset: at91-reset/trivial: driver applies to SAMA5 family as wellNicolas Ferre1-1/+1
This diver doesn't applies only on SAM9 SoC families but on SAMA5 families as well. Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-22power/reset: at91-reset: get and use slow clockAlexandre Belloni1-1/+16
Commit dca1a4b5ff6e ("clk: at91: keep slow clk enabled to prevent system hang") added a workaround for the slow clock as it is not properly handled by its users. Get and use the slow clock as it is necessary for the at91 reset controller. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-22power/reset: at91-reset: allow compiling as a moduleAlexandre Belloni1-3/+14
It was not possible to compile at91-reset as a module. Implement .remove() to allow it. Also switch to module_platform_driver_probe() as it is not hotpluggable. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-09-22power/reset: at91-reset: remove useless at91_reset_platform_probe()Alexandre Belloni1-44/+3
Since all the at91 platforms are now DT only, at91_reset_platform_probe() is now useless, remove it. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
2015-07-20power: reset: at91: add sama5d3 reset functionJosh Wu1-7/+19
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-05-23power: at91-reset: Constify platform_device_idKrzysztof Kozlowski1-1/+1
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-04-30power/reset: at91: fix return value check in at91_reset_platform_probe()Wei Yongjun1-2/+2
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: ecfe64d8c55f ("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-03-26power/reset: at91: big endian fixes for atsama5d3xBen Dooks1-4/+4
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-20power: constify of_device_id arrayFabian Frederick1-2/+2
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-01-26power/reset: at91: Register with kernel restart handlerGuenter Roeck1-10/+18
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>
2014-11-13ARM: at91: move sdramc/ddrsdr header to include/soc/at91Alexandre Belloni1-2/+2
Move the (DDR) SDRAM controller headers to include/soc/at91 to remove the dependency on mach/ headers from the at91-reset driver. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
2014-10-22power: reset: at91-reset: fix power down registerAlexandre Belloni1-2/+2
In the case of at91sam9g45_restart(), the driver is writing AT91_DDRSDRC_LPCB_POWER_DOWN to AT91_DDRSDRC_RTR, this should actually be AT91_DDRSDRC_LPR. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Acked-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
2014-07-15power: reset: Add AT91 reset driverMaxime Ripard1-0/+252
Implement the reset behaviour of the various AT91 SoCS in drivers/power/reset. It used to be (and still is) located in arch/arm/mach-at91, and in order to preserve bisectability is not removed yet, but every board should be converted to use this driver instead. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>