All of lore.kernel.org
 help / color / mirror / Atom feed
From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 04/15] ARM: smp_twd: add device tree support
Date: Mon, 16 Jan 2012 09:59:44 -0600	[thread overview]
Message-ID: <4F144970.5070000@gmail.com> (raw)
In-Reply-To: <1326721960-2224-5-git-send-email-marc.zyngier@arm.com>

On 01/16/2012 07:52 AM, Marc Zyngier wrote:
> Add bindings to support DT discovery of the ARM Timer Watchdog
> (aka TWD). Only the timer side is converted by this patch.
> 
> Cc: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---

Acked-by: Rob Herring <rob.herring@calxeda.com>

>  Documentation/devicetree/bindings/arm/twd.txt |   48 +++++++++++++++
>  arch/arm/include/asm/smp_twd.h                |    8 +++
>  arch/arm/kernel/smp_twd.c                     |   77 ++++++++++++++++++++----
>  3 files changed, 120 insertions(+), 13 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/arm/twd.txt
> 
> diff --git a/Documentation/devicetree/bindings/arm/twd.txt b/Documentation/devicetree/bindings/arm/twd.txt
> new file mode 100644
> index 0000000..75b8610
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/twd.txt
> @@ -0,0 +1,48 @@
> +* ARM Timer Watchdog
> +
> +ARM 11MP, Cortex-A5 and Cortex-A9 are often associated with a per-core
> +Timer-Watchdog (aka TWD), which provides both a per-cpu local timer
> +and watchdog.
> +
> +The TWD is usually attached to a GIC to deliver its two per-processor
> +interrupts.
> +
> +** Timer node required properties:
> +
> +- compatible : Should be one of:
> +	"arm,cortex-a9-twd-timer"
> +	"arm,cortex-a5-twd-timer"
> +	"arm,arm11mp-twd-timer"
> +
> +- interrupts : One interrupt to each core
> +
> +- reg : Specify the base address and the size of the TWD timer
> +	register window.
> +
> +Example:
> +
> +	twd-timer at 2c000600 {
> +		compatible = "arm,arm11mp-twd-timer"";
> +		reg = <0x2c000600 0x20>;
> +		interrupts = <1 13 0xf01>;
> +	};
> +
> +** Watchdog node properties:
> +
> +- compatible : Should be one of:
> +	"arm,cortex-a9-twd-wdt"
> +	"arm,cortex-a5-twd-wdt"
> +	"arm,arm11mp-twd-wdt"
> +
> +- interrupts : One interrupt to each core
> +
> +- reg : Specify the base address and the size of the TWD watchdog
> +	register window.
> +
> +Example:
> +
> +	twd-watchdog at 2c000620 {
> +		compatible = "arm,arm11mp-twd-wdt";
> +		reg = <0x2c000620 0x20>;
> +		interrupts = <1 14 0xf01>;
> +	};
> diff --git a/arch/arm/include/asm/smp_twd.h b/arch/arm/include/asm/smp_twd.h
> index 16c89b7..23c5bc4 100644
> --- a/arch/arm/include/asm/smp_twd.h
> +++ b/arch/arm/include/asm/smp_twd.h
> @@ -40,4 +40,12 @@ struct twd_local_timer name __initdata = {	\
>  
>  int twd_local_timer_register(struct twd_local_timer *);
>  
> +#if CONFIG_HAVE_ARM_TWD
> +void twd_local_timer_of_register(void);
> +#else
> +static inline void twd_local_timer_of_register(void)
> +{
> +}
> +#endif
> +
>  #endif
> diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
> index f105e91..d2dce64 100644
> --- a/arch/arm/kernel/smp_twd.c
> +++ b/arch/arm/kernel/smp_twd.c
> @@ -20,6 +20,8 @@
>  #include <linux/clockchips.h>
>  #include <linux/irq.h>
>  #include <linux/io.h>
> +#include <linux/of_irq.h>
> +#include <linux/of_address.h>
>  
>  #include <asm/smp_twd.h>
>  #include <asm/localtimer.h>
> @@ -282,37 +284,86 @@ static struct local_timer_ops twd_lt_ops __cpuinitdata = {
>  	.stop	= twd_timer_stop,
>  };
>  
> -int __init twd_local_timer_register(struct twd_local_timer *tlt)
> +static int __init twd_local_timer_common_register(void)
>  {
>  	int err;
>  
> -	if (twd_base || twd_evt)
> -		return -EBUSY;
> -
> -	twd_ppi	= tlt->res[1].start;
> -
>  	twd_evt = alloc_percpu(struct clock_event_device *);
> -	twd_base = ioremap(tlt->res[0].start, resource_size(&tlt->res[0]));
> -	if (!twd_base || !twd_evt) {
> +	if (!twd_evt) {
>  		err = -ENOMEM;
> -		goto out;
> +		goto out_free;
>  	}
>  
>  	err = request_percpu_irq(twd_ppi, twd_handler, "twd", twd_evt);
>  	if (err) {
>  		pr_err("twd: can't register interrupt %d (%d)\n", twd_ppi, err);
> -		goto out;
> +		goto out_free;
>  	}
>  
>  	err = local_timer_register(&twd_lt_ops);
>  	if (err)
> -		goto out;
> +		goto out_irq;
>  
>  	return 0;
>  
> -out:
> +out_irq:
> +	free_percpu_irq(twd_ppi, twd_evt);
> +out_free:
>  	iounmap(twd_base);
> +	twd_base = NULL;
>  	free_percpu(twd_evt);
> -	twd_base = twd_evt = NULL;
> +
>  	return err;
>  }
> +
> +int __init twd_local_timer_register(struct twd_local_timer *tlt)
> +{
> +	if (twd_base || twd_evt)
> +		return -EBUSY;
> +
> +	twd_ppi	= tlt->res[1].start;
> +
> +	twd_base = ioremap(tlt->res[0].start, resource_size(&tlt->res[0]));
> +	if (!twd_base)
> +		return -ENOMEM;
> +
> +	return twd_local_timer_common_register();
> +}
> +
> +#ifdef CONFIG_OF
> +const static struct of_device_id twd_of_match[] __initconst = {
> +	{ .compatible = "arm,cortex-a9-twd-timer",	},
> +	{ .compatible = "arm,cortex-a5-twd-timer",	},
> +	{ .compatible = "arm,arm11mp-twd-timer",	},
> +	{ },
> +};
> +
> +void __init twd_local_timer_of_register(void)
> +{
> +	struct device_node *np;
> +	int err;
> +
> +	np = of_find_matching_node(NULL, twd_of_match);
> +	if (!np) {
> +		err = -ENODEV;
> +		goto out;
> +	}
> +
> +	twd_ppi = irq_of_parse_and_map(np, 0);
> +	if (!twd_ppi) {
> +		err = -EINVAL;
> +		goto out;
> +	}
> +
> +	twd_base = of_iomap(np, 0);
> +	if (!twd_base) {
> +		err = -ENOMEM;
> +		goto out;
> +	}
> +
> +	err = twd_local_timer_common_register();
> +
> +out:
> +	WARN(err, "twd_local_timer_of_register failed (%d)\n", err);
> +}
> +#endif

  reply	other threads:[~2012-01-16 15:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-16 13:52 [PATCH v3 00/15] Runtime registration for local timers Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 01/15] ARM: smp_twd: make local_timer_stop a symbol instead of a #define Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 02/15] ARM: local timers: introduce a new registration interface Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 03/15] ARM: smp_twd: add runtime registration support Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 04/15] ARM: smp_twd: add device tree support Marc Zyngier
2012-01-16 15:59   ` Rob Herring [this message]
2012-01-16 13:52 ` [PATCH v3 05/15] ARM: OMAP4: convert to twd_local_timer_register() interface Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 06/15] ARM: plat-versatile: " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 07/15] ARM: tegra: " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 08/15] ARM: shmobile: " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 09/15] ARM: ux500: " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 10/15] ARM: highbank: " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 11/15] ARM: imx6q: " Marc Zyngier
2012-01-17  3:29   ` Shawn Guo
2012-01-16 13:52 ` [PATCH v3 12/15] ARM: smp_twd: remove old local timer interface Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 13/15] ARM: local timers: convert exynos to runtime registration interface Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 14/15] ARM: local timers: convert MSM " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 15/15] ARM: local timers: make the runtime registration interface mandatory Marc Zyngier

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=4F144970.5070000@gmail.com \
    --to=robherring2@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.