1 From 4b9227ba510562a51e87487905895aea97e17e77 Mon Sep 17 00:00:00 2001
2 From: pankaj chauhan <pankaj.chauhan@freescale.com>
3 Date: Tue, 3 Feb 2015 13:08:52 +0530
4 Subject: [PATCH 36/70] ls2085a: Add support for reset
6 Add support for layerscape reset driver.
7 Reset is implemented by raising RESET_REQ_B.
9 Signed-off-by: pankaj chauhan <pankaj.chauhan@freescale.com>
10 Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
11 (cherry picked from commit f248be3aea58ca32b7d77413d742996249b293e9)
13 drivers/power/reset/Kconfig | 7 ++-
14 drivers/power/reset/Makefile | 1 +
15 drivers/power/reset/ls-reboot.c | 93 +++++++++++++++++++++++++++++++++++++++
16 3 files changed, 100 insertions(+), 1 deletion(-)
17 create mode 100644 drivers/power/reset/ls-reboot.c
19 --- a/drivers/power/reset/Kconfig
20 +++ b/drivers/power/reset/Kconfig
21 @@ -173,5 +173,10 @@ config POWER_RESET_ZX
23 Reboot support for ZTE SoCs.
26 +config POWER_RESET_LAYERSCAPE
27 + bool "Freescale LayerScape reset driver"
28 + depends on ARCH_FSL_LS2085A
30 + Reboot support for the Freescale LayerScape SoCs.
33 --- a/drivers/power/reset/Makefile
34 +++ b/drivers/power/reset/Makefile
35 @@ -20,3 +20,4 @@ obj-$(CONFIG_POWER_RESET_SYSCON) += sysc
36 obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) += syscon-poweroff.o
37 obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o
38 obj-$(CONFIG_POWER_RESET_ZX) += zx-reboot.o
39 +obj-$(CONFIG_POWER_RESET_LAYERSCAPE) += ls-reboot.o
41 +++ b/drivers/power/reset/ls-reboot.c
44 + * Freescale LayerScape reboot driver
46 + * Copyright (c) 2015, Freescale Semiconductor.
47 + * Author: Pankaj Chauhan <pankaj.chauhan@freescale.com>
49 + * This program is free software; you can redistribute it and/or modify
50 + * it under the terms of the GNU General Public License version 2 as
51 + * published by the Free Software Foundation.
53 + * This program is distributed in the hope that it will be useful,
54 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
55 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56 + * GNU General Public License for more details.
58 + * You should have received a copy of the GNU General Public License
59 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
62 +#include <linux/io.h>
63 +#include <linux/of_device.h>
64 +#include <linux/of_address.h>
65 +#include <linux/platform_device.h>
66 +#include <linux/stat.h>
67 +#include <linux/slab.h>
68 +#include <asm/system_misc.h>
70 +struct ls_reboot_priv {
75 +static struct ls_reboot_priv *ls_reboot_priv;
77 +static void ls_reboot(enum reboot_mode reboot_mode, const char *cmd)
79 + struct ls_reboot_priv *priv = ls_reboot_priv;
81 + unsigned long timeout;
83 + if (ls_reboot_priv) {
84 + val = readl(priv->rstcr);
86 + writel(val, priv->rstcr);
89 + timeout = jiffies + HZ;
90 + while (time_before(jiffies, timeout))
95 +static int ls_reboot_probe(struct platform_device *pdev)
97 + ls_reboot_priv = devm_kzalloc(&pdev->dev,
98 + sizeof(*ls_reboot_priv), GFP_KERNEL);
99 + if (!ls_reboot_priv) {
100 + dev_err(&pdev->dev, "out of memory for context\n");
104 + ls_reboot_priv->rstcr = of_iomap(pdev->dev.of_node, 0);
105 + if (!ls_reboot_priv->rstcr) {
106 + devm_kfree(&pdev->dev, ls_reboot_priv);
107 + dev_err(&pdev->dev, "can not map resource\n");
111 + ls_reboot_priv->dev = &pdev->dev;
113 + arm_pm_restart = ls_reboot;
118 +static struct of_device_id ls_reboot_of_match[] = {
119 + { .compatible = "fsl,ls-reset" },
123 +static struct platform_driver ls_reboot_driver = {
124 + .probe = ls_reboot_probe,
126 + .name = "ls-reset",
127 + .of_match_table = ls_reboot_of_match,
131 +static int __init ls_reboot_init(void)
133 + return platform_driver_register(&ls_reboot_driver);
135 +device_initcall(ls_reboot_init);