lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 27 Mar 2024 00:31:12 +0100
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: nikita.shubin@...uefel.me
Cc: linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org, 
	Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v9 05/38] power: reset: Add a driver for the ep93xx reset

Hi,

On Tue, Mar 26, 2024 at 12:18:32PM +0300, Nikita Shubin via B4 Relay wrote:
> From: Nikita Shubin <nikita.shubin@...uefel.me>
> 
> Implement the reset behaviour of the various EP93xx SoCS
> in drivers/power/reset.
> 
> It used to be located in arch/arm/mach-ep93xx.
> 
> Signed-off-by: Nikita Shubin <nikita.shubin@...uefel.me>
> Acked-by: Sebastian Reichel <sre@...nel.org>
> ---

If another round is needed, please use devm_register_sys_off_handler()
instead of register_restart_handler().

Greetings,

-- Sebastian

>  drivers/power/reset/Kconfig          | 10 +++++
>  drivers/power/reset/Makefile         |  1 +
>  drivers/power/reset/ep93xx-restart.c | 84 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 95 insertions(+)
> 
> diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
> index fece990af4a7..389d5a193e5d 100644
> --- a/drivers/power/reset/Kconfig
> +++ b/drivers/power/reset/Kconfig
> @@ -75,6 +75,16 @@ config POWER_RESET_BRCMSTB
>  	  Say Y here if you have a Broadcom STB board and you wish
>  	  to have restart support.
>  
> +config POWER_RESET_EP93XX
> +	bool "Cirrus EP93XX reset driver" if COMPILE_TEST
> +	depends on MFD_SYSCON
> +	default ARCH_EP93XX
> +	help
> +	  This driver provides restart support for Cirrus EP93XX SoC.
> +
> +	  Say Y here if you have a Cirrus EP93XX SoC and you wish
> +	  to have restart support.
> +
>  config POWER_RESET_GEMINI_POWEROFF
>  	bool "Cortina Gemini power-off driver"
>  	depends on ARCH_GEMINI || COMPILE_TEST
> diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
> index a95d1bd275d1..10782d32e1da 100644
> --- a/drivers/power/reset/Makefile
> +++ b/drivers/power/reset/Makefile
> @@ -7,6 +7,7 @@ obj-$(CONFIG_POWER_RESET_ATC260X) += atc260x-poweroff.o
>  obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o
>  obj-$(CONFIG_POWER_RESET_BRCMKONA) += brcm-kona-reset.o
>  obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o
> +obj-$(CONFIG_POWER_RESET_EP93XX) += ep93xx-restart.o
>  obj-$(CONFIG_POWER_RESET_GEMINI_POWEROFF) += gemini-poweroff.o
>  obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
>  obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o
> diff --git a/drivers/power/reset/ep93xx-restart.c b/drivers/power/reset/ep93xx-restart.c
> new file mode 100644
> index 000000000000..57cfb8620faf
> --- /dev/null
> +++ b/drivers/power/reset/ep93xx-restart.c
> @@ -0,0 +1,84 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Cirrus EP93xx SoC reset driver
> + *
> + * Copyright (C) 2021 Nikita Shubin <nikita.shubin@...uefel.me>
> + */
> +
> +#include <linux/bits.h>
> +#include <linux/container_of.h>
> +#include <linux/delay.h>
> +#include <linux/errno.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/notifier.h>
> +#include <linux/reboot.h>
> +#include <linux/slab.h>
> +
> +#include <linux/soc/cirrus/ep93xx.h>
> +
> +#define EP93XX_SYSCON_DEVCFG		0x80
> +#define EP93XX_SYSCON_DEVCFG_SWRST	BIT(31)
> +
> +struct ep93xx_restart {
> +	struct ep93xx_regmap_adev *aux_dev;
> +	struct notifier_block restart_handler;
> +};
> +
> +static int ep93xx_restart_handle(struct notifier_block *this,
> +				 unsigned long mode, void *cmd)
> +{
> +	struct ep93xx_restart *priv =
> +		container_of(this, struct ep93xx_restart, restart_handler);
> +	struct ep93xx_regmap_adev *aux = priv->aux_dev;
> +
> +	/* Issue the reboot */
> +	aux->update_bits(aux->map, aux->lock, EP93XX_SYSCON_DEVCFG,
> +			 EP93XX_SYSCON_DEVCFG_SWRST, EP93XX_SYSCON_DEVCFG_SWRST);
> +	aux->update_bits(aux->map, aux->lock, EP93XX_SYSCON_DEVCFG,
> +			 EP93XX_SYSCON_DEVCFG_SWRST, 0);
> +
> +	return NOTIFY_DONE;
> +}
> +
> +static int ep93xx_reboot_probe(struct auxiliary_device *adev,
> +			       const struct auxiliary_device_id *id)
> +{
> +	struct ep93xx_regmap_adev *rdev = to_ep93xx_regmap_adev(adev);
> +	struct device *dev = &adev->dev;
> +	struct ep93xx_restart *priv;
> +	int err;
> +
> +	if (!rdev->update_bits)
> +		return -ENODEV;
> +
> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
> +	priv->aux_dev = rdev;
> +
> +	priv->restart_handler.notifier_call = ep93xx_restart_handle;
> +	priv->restart_handler.priority = 128;
> +
> +	err = register_restart_handler(&priv->restart_handler);
> +	if (err)
> +		return dev_err_probe(dev, err, "can't register restart notifier\n");
> +
> +	return 0;
> +}
> +
> +static const struct auxiliary_device_id ep93xx_reboot_ids[] = {
> +	{
> +		.name = "soc_ep93xx.reset-ep93xx",
> +	},
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(auxiliary, ep93xx_reboot_ids);
> +
> +static struct auxiliary_driver ep93xx_reboot_driver = {
> +	.probe		= ep93xx_reboot_probe,
> +	.id_table	= ep93xx_reboot_ids,
> +};
> +module_auxiliary_driver(ep93xx_reboot_driver);
> 
> -- 
> 2.41.0
> 
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ