1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2014 Marvell
5 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
8 #define pr_fmt(fmt) "mvebu-cpureset: " fmt
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/of_address.h>
14 #include <linux/resource.h>
18 static void __iomem *cpu_reset_base;
19 static size_t cpu_reset_size;
21 #define CPU_RESET_OFFSET(cpu) (cpu * 0x8)
22 #define CPU_RESET_ASSERT BIT(0)
24 int mvebu_cpu_reset_deassert(int cpu)
31 if (CPU_RESET_OFFSET(cpu) >= cpu_reset_size)
34 reg = readl(cpu_reset_base + CPU_RESET_OFFSET(cpu));
35 reg &= ~CPU_RESET_ASSERT;
36 writel(reg, cpu_reset_base + CPU_RESET_OFFSET(cpu));
41 static int mvebu_cpu_reset_map(struct device_node *np, int res_idx)
45 if (of_address_to_resource(np, res_idx, &res)) {
46 pr_err("unable to get resource\n");
50 if (!request_mem_region(res.start, resource_size(&res),
52 pr_err("unable to request region\n");
56 cpu_reset_base = ioremap(res.start, resource_size(&res));
57 if (!cpu_reset_base) {
58 pr_err("unable to map registers\n");
59 release_mem_region(res.start, resource_size(&res));
63 cpu_reset_size = resource_size(&res);
68 static int __init mvebu_cpu_reset_init(void)
70 struct device_node *np;
74 np = of_find_compatible_node(NULL, NULL,
75 "marvell,armada-370-cpu-reset");
80 * This code is kept for backward compatibility with
83 np = of_find_compatible_node(NULL, NULL,
84 "marvell,armada-370-xp-pmsu");
86 pr_warn(FW_WARN "deprecated pmsu binding\n");
91 /* No reset node found */
95 ret = mvebu_cpu_reset_map(np, res_idx);
101 early_initcall(mvebu_cpu_reset_init);