You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openwrt/target/linux/layerscape/patches-4.4/8036-ls2085a-Add-support-fo...

136 lines
3.8 KiB
Diff

From 4b9227ba510562a51e87487905895aea97e17e77 Mon Sep 17 00:00:00 2001
From: pankaj chauhan <pankaj.chauhan@freescale.com>
Date: Tue, 3 Feb 2015 13:08:52 +0530
Subject: [PATCH 36/70] ls2085a: Add support for reset
Add support for layerscape reset driver.
Reset is implemented by raising RESET_REQ_B.
Signed-off-by: pankaj chauhan <pankaj.chauhan@freescale.com>
Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
(cherry picked from commit f248be3aea58ca32b7d77413d742996249b293e9)
---
drivers/power/reset/Kconfig | 7 ++-
drivers/power/reset/Makefile | 1 +
drivers/power/reset/ls-reboot.c | 93 +++++++++++++++++++++++++++++++++++++++
3 files changed, 100 insertions(+), 1 deletion(-)
create mode 100644 drivers/power/reset/ls-reboot.c
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -173,5 +173,10 @@ config POWER_RESET_ZX
help
Reboot support for ZTE SoCs.
-endif
+config POWER_RESET_LAYERSCAPE
+ bool "Freescale LayerScape reset driver"
+ depends on ARCH_FSL_LS2085A
+ help
+ Reboot support for the Freescale LayerScape SoCs.
+endif
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -20,3 +20,4 @@ obj-$(CONFIG_POWER_RESET_SYSCON) += sysc
obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) += syscon-poweroff.o
obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o
obj-$(CONFIG_POWER_RESET_ZX) += zx-reboot.o
+obj-$(CONFIG_POWER_RESET_LAYERSCAPE) += ls-reboot.o
--- /dev/null
+++ b/drivers/power/reset/ls-reboot.c
@@ -0,0 +1,93 @@
+/*
+ * Freescale LayerScape reboot driver
+ *
+ * Copyright (c) 2015, Freescale Semiconductor.
+ * Author: Pankaj Chauhan <pankaj.chauhan@freescale.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/io.h>
+#include <linux/of_device.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/stat.h>
+#include <linux/slab.h>
+#include <asm/system_misc.h>
+
+struct ls_reboot_priv {
+ struct device *dev;
+ u32 *rstcr;
+};
+
+static struct ls_reboot_priv *ls_reboot_priv;
+
+static void ls_reboot(enum reboot_mode reboot_mode, const char *cmd)
+{
+ struct ls_reboot_priv *priv = ls_reboot_priv;
+ u32 val;
+ unsigned long timeout;
+
+ if (ls_reboot_priv) {
+ val = readl(priv->rstcr);
+ val |= 0x02;
+ writel(val, priv->rstcr);
+ }
+
+ timeout = jiffies + HZ;
+ while (time_before(jiffies, timeout))
+ cpu_relax();
+
+}
+
+static int ls_reboot_probe(struct platform_device *pdev)
+{
+ ls_reboot_priv = devm_kzalloc(&pdev->dev,
+ sizeof(*ls_reboot_priv), GFP_KERNEL);
+ if (!ls_reboot_priv) {
+ dev_err(&pdev->dev, "out of memory for context\n");
+ return -ENODEV;
+ }
+
+ ls_reboot_priv->rstcr = of_iomap(pdev->dev.of_node, 0);
+ if (!ls_reboot_priv->rstcr) {
+ devm_kfree(&pdev->dev, ls_reboot_priv);
+ dev_err(&pdev->dev, "can not map resource\n");
+ return -ENODEV;
+ }
+
+ ls_reboot_priv->dev = &pdev->dev;
+
+ arm_pm_restart = ls_reboot;
+
+ return 0;
+}
+
+static struct of_device_id ls_reboot_of_match[] = {
+ { .compatible = "fsl,ls-reset" },
+ {}
+};
+
+static struct platform_driver ls_reboot_driver = {
+ .probe = ls_reboot_probe,
+ .driver = {
+ .name = "ls-reset",
+ .of_match_table = ls_reboot_of_match,
+ },
+};
+
+static int __init ls_reboot_init(void)
+{
+ return platform_driver_register(&ls_reboot_driver);
+}
+device_initcall(ls_reboot_init);