kernel: update kernel 4.4 to version 4.4.30
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.4 / 8036-ls2085a-Add-support-for-reset.patch
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
5
6 Add support for layerscape reset driver.
7 Reset is implemented by raising RESET_REQ_B.
8
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)
12 ---
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
18
19 --- a/drivers/power/reset/Kconfig
20 +++ b/drivers/power/reset/Kconfig
21 @@ -173,5 +173,10 @@ config POWER_RESET_ZX
22 help
23 Reboot support for ZTE SoCs.
24
25 -endif
26 +config POWER_RESET_LAYERSCAPE
27 + bool "Freescale LayerScape reset driver"
28 + depends on ARCH_FSL_LS2085A
29 + help
30 + Reboot support for the Freescale LayerScape SoCs.
31
32 +endif
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
40 --- /dev/null
41 +++ b/drivers/power/reset/ls-reboot.c
42 @@ -0,0 +1,93 @@
43 +/*
44 + * Freescale LayerScape reboot driver
45 + *
46 + * Copyright (c) 2015, Freescale Semiconductor.
47 + * Author: Pankaj Chauhan <pankaj.chauhan@freescale.com>
48 + *
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.
52 + *
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.
57 + *
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/>.
60 + */
61 +
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>
69 +
70 +struct ls_reboot_priv {
71 + struct device *dev;
72 + u32 *rstcr;
73 +};
74 +
75 +static struct ls_reboot_priv *ls_reboot_priv;
76 +
77 +static void ls_reboot(enum reboot_mode reboot_mode, const char *cmd)
78 +{
79 + struct ls_reboot_priv *priv = ls_reboot_priv;
80 + u32 val;
81 + unsigned long timeout;
82 +
83 + if (ls_reboot_priv) {
84 + val = readl(priv->rstcr);
85 + val |= 0x02;
86 + writel(val, priv->rstcr);
87 + }
88 +
89 + timeout = jiffies + HZ;
90 + while (time_before(jiffies, timeout))
91 + cpu_relax();
92 +
93 +}
94 +
95 +static int ls_reboot_probe(struct platform_device *pdev)
96 +{
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");
101 + return -ENODEV;
102 + }
103 +
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");
108 + return -ENODEV;
109 + }
110 +
111 + ls_reboot_priv->dev = &pdev->dev;
112 +
113 + arm_pm_restart = ls_reboot;
114 +
115 + return 0;
116 +}
117 +
118 +static struct of_device_id ls_reboot_of_match[] = {
119 + { .compatible = "fsl,ls-reset" },
120 + {}
121 +};
122 +
123 +static struct platform_driver ls_reboot_driver = {
124 + .probe = ls_reboot_probe,
125 + .driver = {
126 + .name = "ls-reset",
127 + .of_match_table = ls_reboot_of_match,
128 + },
129 +};
130 +
131 +static int __init ls_reboot_init(void)
132 +{
133 + return platform_driver_register(&ls_reboot_driver);
134 +}
135 +device_initcall(ls_reboot_init);