@@ -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
@@ -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
new file mode 100644
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: (GPL-2.0)
+/*
+ * Cirrus EP93xx SoC reset driver
+ *
+ * Copyright (C) 2021 Nikita Shubin <nikita.shubin@maquefel.me>
+ */
+
+#include <linux/delay.h>
+#include <linux/notifier.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/reboot.h>
+
+#include <linux/soc/cirrus/ep93xx.h>
+
+#define EP93XX_SYSCON_DEVCFG_SWRST BIT(31)
+
+static int ep93xx_restart_handle(struct notifier_block *this,
+ unsigned long mode, void *cmd)
+{
+ /* Issue the reboot */
+ ep93xx_devcfg_set_clear(EP93XX_SYSCON_DEVCFG_SWRST, 0x00);
+ ep93xx_devcfg_set_clear(0x00, EP93XX_SYSCON_DEVCFG_SWRST);
+
+ mdelay(1000);
+
+ pr_emerg("Unable to restart system\n");
+ return NOTIFY_DONE;
+}
+
+static int ep93xx_reboot_probe(struct platform_device *pdev)
+{
+ struct notifier_block *res_han;
+ struct device *dev = &pdev->dev;
+ int err;
+
+ res_han = devm_kzalloc(&pdev->dev, sizeof(*res_han), GFP_KERNEL);
+ if (!res_han)
+ return -ENOMEM;
+
+ res_han->notifier_call = ep93xx_restart_handle;
+ res_han->priority = 128;
+
+ err = register_restart_handler(res_han);
+ if (err)
+ dev_err(dev, "can't register restart notifier (err=%d)\n", err);
+
+ return err;
+}
+
+static const struct of_device_id ep93xx_reboot_of_match[] = {
+ {
+ .compatible = "cirrus,ep9301-reboot",
+ },
+ {}
+};
+
+static struct platform_driver ep93xx_reboot_driver = {
+ .probe = ep93xx_reboot_probe,
+ .driver = {
+ .name = "ep9301-reboot",
+ .of_match_table = ep93xx_reboot_of_match,
+ },
+};
+builtin_platform_driver(ep93xx_reboot_driver);