diff options
Diffstat (limited to 'arch/arm/mach-mvebu')
-rw-r--r-- | arch/arm/mach-mvebu/cpu-reset.c | 53 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/pmsu.c | 20 |
2 files changed, 47 insertions, 26 deletions
diff --git a/arch/arm/mach-mvebu/cpu-reset.c b/arch/arm/mach-mvebu/cpu-reset.c index 4ff4ce77f8b6..4a8f9eebebea 100644 --- a/arch/arm/mach-mvebu/cpu-reset.c +++ b/arch/arm/mach-mvebu/cpu-reset.c | |||
@@ -40,42 +40,63 @@ int mvebu_cpu_reset_deassert(int cpu) | |||
40 | return 0; | 40 | return 0; |
41 | } | 41 | } |
42 | 42 | ||
43 | static int __init mvebu_cpu_reset_init(void) | 43 | static int mvebu_cpu_reset_map(struct device_node *np, int res_idx) |
44 | { | 44 | { |
45 | struct device_node *np; | ||
46 | struct resource res; | 45 | struct resource res; |
47 | int ret = 0; | ||
48 | |||
49 | np = of_find_compatible_node(NULL, NULL, | ||
50 | "marvell,armada-370-cpu-reset"); | ||
51 | if (!np) | ||
52 | return 0; | ||
53 | 46 | ||
54 | if (of_address_to_resource(np, 0, &res)) { | 47 | if (of_address_to_resource(np, res_idx, &res)) { |
55 | pr_err("unable to get resource\n"); | 48 | pr_err("unable to get resource\n"); |
56 | ret = -ENOENT; | 49 | return -ENOENT; |
57 | goto out; | ||
58 | } | 50 | } |
59 | 51 | ||
60 | if (!request_mem_region(res.start, resource_size(&res), | 52 | if (!request_mem_region(res.start, resource_size(&res), |
61 | np->full_name)) { | 53 | np->full_name)) { |
62 | pr_err("unable to request region\n"); | 54 | pr_err("unable to request region\n"); |
63 | ret = -EBUSY; | 55 | return -EBUSY; |
64 | goto out; | ||
65 | } | 56 | } |
66 | 57 | ||
67 | cpu_reset_base = ioremap(res.start, resource_size(&res)); | 58 | cpu_reset_base = ioremap(res.start, resource_size(&res)); |
68 | if (!cpu_reset_base) { | 59 | if (!cpu_reset_base) { |
69 | pr_err("unable to map registers\n"); | 60 | pr_err("unable to map registers\n"); |
70 | release_mem_region(res.start, resource_size(&res)); | 61 | release_mem_region(res.start, resource_size(&res)); |
71 | ret = -ENOMEM; | 62 | return -ENOMEM; |
72 | goto out; | ||
73 | } | 63 | } |
74 | 64 | ||
75 | cpu_reset_size = resource_size(&res); | 65 | cpu_reset_size = resource_size(&res); |
76 | 66 | ||
77 | out: | 67 | return 0; |
68 | } | ||
69 | |||
70 | int __init mvebu_cpu_reset_init(void) | ||
71 | { | ||
72 | struct device_node *np; | ||
73 | int res_idx; | ||
74 | int ret; | ||
75 | |||
76 | np = of_find_compatible_node(NULL, NULL, | ||
77 | "marvell,armada-370-cpu-reset"); | ||
78 | if (np) { | ||
79 | res_idx = 0; | ||
80 | } else { | ||
81 | /* | ||
82 | * This code is kept for backward compatibility with | ||
83 | * old Device Trees. | ||
84 | */ | ||
85 | np = of_find_compatible_node(NULL, NULL, | ||
86 | "marvell,armada-370-xp-pmsu"); | ||
87 | if (np) { | ||
88 | pr_warn(FW_WARN "deprecated pmsu binding\n"); | ||
89 | res_idx = 1; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | /* No reset node found */ | ||
94 | if (!np) | ||
95 | return -ENODEV; | ||
96 | |||
97 | ret = mvebu_cpu_reset_map(np, res_idx); | ||
78 | of_node_put(np); | 98 | of_node_put(np); |
99 | |||
79 | return ret; | 100 | return ret; |
80 | } | 101 | } |
81 | 102 | ||
diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c index d71ef53107c4..1807639173b1 100644 --- a/arch/arm/mach-mvebu/pmsu.c +++ b/arch/arm/mach-mvebu/pmsu.c | |||
@@ -21,14 +21,14 @@ | |||
21 | #include <linux/of_address.h> | 21 | #include <linux/of_address.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/smp.h> | 23 | #include <linux/smp.h> |
24 | #include <linux/resource.h> | ||
24 | #include <asm/smp_plat.h> | 25 | #include <asm/smp_plat.h> |
26 | #include "common.h" | ||
25 | #include "pmsu.h" | 27 | #include "pmsu.h" |
26 | 28 | ||
27 | static void __iomem *pmsu_mp_base; | 29 | static void __iomem *pmsu_mp_base; |
28 | static void __iomem *pmsu_reset_base; | ||
29 | 30 | ||
30 | #define PMSU_BOOT_ADDR_REDIRECT_OFFSET(cpu) ((cpu * 0x100) + 0x24) | 31 | #define PMSU_BOOT_ADDR_REDIRECT_OFFSET(cpu) ((cpu * 0x100) + 0x24) |
31 | #define PMSU_RESET_CTL_OFFSET(cpu) (cpu * 0x8) | ||
32 | 32 | ||
33 | static struct of_device_id of_pmsu_table[] = { | 33 | static struct of_device_id of_pmsu_table[] = { |
34 | {.compatible = "marvell,armada-370-xp-pmsu"}, | 34 | {.compatible = "marvell,armada-370-xp-pmsu"}, |
@@ -38,11 +38,11 @@ static struct of_device_id of_pmsu_table[] = { | |||
38 | #ifdef CONFIG_SMP | 38 | #ifdef CONFIG_SMP |
39 | int armada_xp_boot_cpu(unsigned int cpu_id, void *boot_addr) | 39 | int armada_xp_boot_cpu(unsigned int cpu_id, void *boot_addr) |
40 | { | 40 | { |
41 | int reg, hw_cpu; | 41 | int hw_cpu, ret; |
42 | 42 | ||
43 | if (!pmsu_mp_base || !pmsu_reset_base) { | 43 | if (!pmsu_mp_base) { |
44 | pr_warn("Can't boot CPU. PMSU is uninitialized\n"); | 44 | pr_warn("Can't boot CPU. PMSU is uninitialized\n"); |
45 | return 1; | 45 | return -ENODEV; |
46 | } | 46 | } |
47 | 47 | ||
48 | hw_cpu = cpu_logical_map(cpu_id); | 48 | hw_cpu = cpu_logical_map(cpu_id); |
@@ -50,10 +50,11 @@ int armada_xp_boot_cpu(unsigned int cpu_id, void *boot_addr) | |||
50 | writel(virt_to_phys(boot_addr), pmsu_mp_base + | 50 | writel(virt_to_phys(boot_addr), pmsu_mp_base + |
51 | PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu)); | 51 | PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu)); |
52 | 52 | ||
53 | /* Release CPU from reset by clearing reset bit*/ | 53 | ret = mvebu_cpu_reset_deassert(hw_cpu); |
54 | reg = readl(pmsu_reset_base + PMSU_RESET_CTL_OFFSET(hw_cpu)); | 54 | if (ret) { |
55 | reg &= (~0x1); | 55 | pr_warn("unable to boot CPU: %d\n", ret); |
56 | writel(reg, pmsu_reset_base + PMSU_RESET_CTL_OFFSET(hw_cpu)); | 56 | return ret; |
57 | } | ||
57 | 58 | ||
58 | return 0; | 59 | return 0; |
59 | } | 60 | } |
@@ -67,7 +68,6 @@ static int __init armada_370_xp_pmsu_init(void) | |||
67 | if (np) { | 68 | if (np) { |
68 | pr_info("Initializing Power Management Service Unit\n"); | 69 | pr_info("Initializing Power Management Service Unit\n"); |
69 | pmsu_mp_base = of_iomap(np, 0); | 70 | pmsu_mp_base = of_iomap(np, 0); |
70 | pmsu_reset_base = of_iomap(np, 1); | ||
71 | of_node_put(np); | 71 | of_node_put(np); |
72 | } | 72 | } |
73 | 73 | ||