Commit bd045a1e authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by Jason Cooper

ARM: mvebu: improve PMSU driver to request its resource

Until now, the PMSU driver was using of_iomap() to map its registers,
but of_iomap() doesn't call request_mem_region(). This commit fixes
the memory mapping code of the PMSU to do so, which will also be
useful for a later commit since we will need to adjust the resource
base address and size for Device Tree backward compatibility.
Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Link: https://lkml.kernel.org/r/1397483433-25836-4-git-send-email-thomas.petazzoni@free-electrons.comAcked-by: default avatarGregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: default avatarJason Cooper <jason@lakedaemon.net>
parent 49754ffe
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
* other SOC units * other SOC units
*/ */
#define pr_fmt(fmt) "mvebu-pmsu: " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/of_address.h> #include <linux/of_address.h>
...@@ -63,15 +65,39 @@ int armada_xp_boot_cpu(unsigned int cpu_id, void *boot_addr) ...@@ -63,15 +65,39 @@ int armada_xp_boot_cpu(unsigned int cpu_id, void *boot_addr)
static int __init armada_370_xp_pmsu_init(void) static int __init armada_370_xp_pmsu_init(void)
{ {
struct device_node *np; struct device_node *np;
struct resource res;
int ret = 0;
np = of_find_matching_node(NULL, of_pmsu_table); np = of_find_matching_node(NULL, of_pmsu_table);
if (np) { if (!np)
pr_info("Initializing Power Management Service Unit\n"); return 0;
pmsu_mp_base = of_iomap(np, 0);
of_node_put(np); pr_info("Initializing Power Management Service Unit\n");
if (of_address_to_resource(np, 0, &res)) {
pr_err("unable to get resource\n");
ret = -ENOENT;
goto out;
} }
return 0; if (!request_mem_region(res.start, resource_size(&res),
np->full_name)) {
pr_err("unable to request region\n");
ret = -EBUSY;
goto out;
}
pmsu_mp_base = ioremap(res.start, resource_size(&res));
if (!pmsu_mp_base) {
pr_err("unable to map registers\n");
release_mem_region(res.start, resource_size(&res));
ret = -ENOMEM;
goto out;
}
out:
of_node_put(np);
return ret;
} }
early_initcall(armada_370_xp_pmsu_init); early_initcall(armada_370_xp_pmsu_init);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment