From: gregory.clement@free-electrons•com (Gregory CLEMENT)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH 3/6] ARM: mvebu: improve PMSU driver to request its resource
Date: Thu, 27 Mar 2014 16:59:15 +0100 [thread overview]
Message-ID: <53344AD3.1010503@free-electrons.com> (raw)
In-Reply-To: <1395927485-11842-4-git-send-email-thomas.petazzoni@free-electrons.com>
On 27/03/2014 14:38, Thomas Petazzoni wrote:
> 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: Thomas Petazzoni <thomas.petazzoni@free-electrons•com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons•com>
> ---
> arch/arm/mach-mvebu/pmsu.c | 36 +++++++++++++++++++++++++++++++-----
> 1 file changed, 31 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c
> index 1807639..b337fe5 100644
> --- a/arch/arm/mach-mvebu/pmsu.c
> +++ b/arch/arm/mach-mvebu/pmsu.c
> @@ -16,6 +16,8 @@
> * other SOC units
> */
>
> +#define pr_fmt(fmt) "mvebu-pmsu: " fmt
> +
> #include <linux/kernel.h>
> #include <linux/init.h>
> #include <linux/of_address.h>
> @@ -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)
> {
> struct device_node *np;
> + struct resource res;
> + int ret = 0;
>
> np = of_find_matching_node(NULL, of_pmsu_table);
> - if (np) {
> - pr_info("Initializing Power Management Service Unit\n");
> - pmsu_mp_base = of_iomap(np, 0);
> - of_node_put(np);
> + if (!np)
> + return 0;
> +
> + 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);
>
--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
next prev parent reply other threads:[~2014-03-27 15:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-27 13:37 [PATCH 0/6] ARM: mvebu: prepare PMSU code for cpuidle and Armada 375/38x SMP Thomas Petazzoni
2014-03-27 13:38 ` [PATCH 1/6] ARM: mvebu: introduce CPU reset code Thomas Petazzoni
2014-03-27 14:00 ` Gregory CLEMENT
2014-03-27 14:19 ` Thomas Petazzoni
2014-03-27 15:58 ` Gregory CLEMENT
2014-03-27 14:12 ` Sebastian Hesselbarth
2014-03-27 14:21 ` Thomas Petazzoni
2014-03-27 13:38 ` [PATCH 2/6] ARM: mvebu: start using the CPU reset driver Thomas Petazzoni
2014-03-27 15:58 ` Gregory CLEMENT
2014-03-27 13:38 ` [PATCH 3/6] ARM: mvebu: improve PMSU driver to request its resource Thomas Petazzoni
2014-03-27 15:59 ` Gregory CLEMENT [this message]
2014-03-27 13:38 ` [PATCH 4/6] ARM: mvebu: extend the PMSU registers Thomas Petazzoni
2014-03-27 13:38 ` [PATCH 5/6] ARM: mvebu: switch to the new PMSU binding in Armada 370/XP Device Tree Thomas Petazzoni
2014-03-27 13:38 ` [PATCH 6/6] ARM: mvebu: use a separate function to set the boot address of CPUs Thomas Petazzoni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53344AD3.1010503@free-electrons.com \
--to=gregory.clement@free-electrons$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox