linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 10/19] clocksource: sh_tmu: Add DT support
Date: Tue, 17 Jun 2014 01:11:54 +0000	[thread overview]
Message-ID: <20140617011154.GA32454@verge.net.au> (raw)
In-Reply-To: <1402931251-22581-11-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

Hi Laurent,

This version looks good to me.

On Mon, Jun 16, 2014 at 05:07:22PM +0200, Laurent Pinchart wrote:
> Document DT bindings and parse them in the TMU driver.
> 
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Tested-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  .../devicetree/bindings/timer/renesas,tmu.txt      | 39 +++++++++++++++++
>  drivers/clocksource/sh_tmu.c                       | 51 +++++++++++++++++-----
>  2 files changed, 80 insertions(+), 10 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/timer/renesas,tmu.txt
> 
> diff --git a/Documentation/devicetree/bindings/timer/renesas,tmu.txt b/Documentation/devicetree/bindings/timer/renesas,tmu.txt
> new file mode 100644
> index 0000000..425d0c5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/renesas,tmu.txt
> @@ -0,0 +1,39 @@
> +* Renesas R-Car Timer Unit (TMU)
> +
> +The TMU is a 32-bit timer/counter with configurable clock inputs and
> +programmable compare match.
> +
> +Channels share hardware resources but their counter and compare match value
> +are independent. The TMU hardware supports up to three channels.
> +
> +Required Properties:
> +
> +  - compatible: must contain "renesas,tmu"
> +
> +  - reg: base address and length of the registers block for the timer module.
> +
> +  - interrupts: interrupt-specifier for the timer, one per channel.
> +
> +  - clocks: a list of phandle + clock-specifier pairs, one for each entry
> +    in clock-names.
> +  - clock-names: must contain "fck" for the functional clock.
> +
> +Optional Properties:
> +
> +  - #renesas,channels: number of channels implemented by the timer, must be 2
> +    or 3 (if not specified the value defaults to 3).
> +
> +
> +Example: R8A7779 (R-Car H1) TMU0 node
> +
> +	tmu0: timer@ffd80000 {
> +		compatible = "renesas,tmu";
> +		reg = <0xffd80000 0x30>;
> +		interrupts = <0 32 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 33 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 34 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> +		clock-names = "fck";
> +
> +		#renesas,channels = <3>;
> +	};
> diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
> index ef8fb0b..ed61ed2 100644
> --- a/drivers/clocksource/sh_tmu.c
> +++ b/drivers/clocksource/sh_tmu.c
> @@ -24,6 +24,7 @@
>  #include <linux/ioport.h>
>  #include <linux/irq.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_domain.h>
>  #include <linux/pm_runtime.h>
> @@ -509,23 +510,48 @@ static int sh_tmu_map_memory(struct sh_tmu_device *tmu)
>  	return 0;
>  }
>  
> +static int sh_tmu_parse_dt(struct sh_tmu_device *tmu)
> +{
> +	struct device_node *np = tmu->pdev->dev.of_node;
> +
> +	tmu->model = SH_TMU;
> +	tmu->num_channels = 3;
> +
> +	of_property_read_u32(np, "#renesas,channels", &tmu->num_channels);
> +
> +	if (tmu->num_channels != 2 && tmu->num_channels != 3) {
> +		dev_err(&tmu->pdev->dev, "invalid number of channels %u\n",
> +			tmu->num_channels);
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
>  static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
>  {
> -	struct sh_timer_config *cfg = pdev->dev.platform_data;
> -	const struct platform_device_id *id = pdev->id_entry;
>  	unsigned int i;
>  	int ret;
>  
> -	if (!cfg) {
> -		dev_err(&tmu->pdev->dev, "missing platform data\n");
> -		return -ENXIO;
> -	}
> -
>  	tmu->pdev = pdev;
> -	tmu->model = id->driver_data;
>  
>  	raw_spin_lock_init(&tmu->lock);
>  
> +	if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
> +		ret = sh_tmu_parse_dt(tmu);
> +		if (ret < 0)
> +			return ret;
> +	} else if (pdev->dev.platform_data) {
> +		const struct platform_device_id *id = pdev->id_entry;
> +		struct sh_timer_config *cfg = pdev->dev.platform_data;
> +
> +		tmu->model = id->driver_data;
> +		tmu->num_channels = hweight8(cfg->channels_mask);
> +	} else {
> +		dev_err(&tmu->pdev->dev, "missing platform data\n");
> +		return -ENXIO;
> +	}
> +
>  	/* Get hold of clock. */
>  	tmu->clk = clk_get(&tmu->pdev->dev, "fck");
>  	if (IS_ERR(tmu->clk)) {
> @@ -545,8 +571,6 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
>  	}
>  
>  	/* Allocate and setup the channels. */
> -	tmu->num_channels = hweight8(cfg->channels_mask);
> -
>  	tmu->channels = kzalloc(sizeof(*tmu->channels) * tmu->num_channels,
>  				GFP_KERNEL);
>  	if (tmu->channels = NULL) {
> @@ -630,11 +654,18 @@ static const struct platform_device_id sh_tmu_id_table[] = {
>  };
>  MODULE_DEVICE_TABLE(platform, sh_tmu_id_table);
>  
> +static const struct of_device_id sh_tmu_of_table[] __maybe_unused = {
> +	{ .compatible = "renesas,tmu" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, sh_tmu_of_table);
> +
>  static struct platform_driver sh_tmu_device_driver = {
>  	.probe		= sh_tmu_probe,
>  	.remove		= sh_tmu_remove,
>  	.driver		= {
>  		.name	= "sh_tmu",
> +		.of_match_table = of_match_ptr(sh_tmu_of_table),
>  	},
>  	.id_table	= sh_tmu_id_table,
>  };
> -- 
> 1.8.5.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  reply	other threads:[~2014-06-17  1:11 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16 15:07 [PATCH v4 00/19] Renesas CMT, MTU2 and TMU timers DT support Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 01/19] clocksource: sh_tmu: Fix channel IRQ retrieval in legacy case Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 02/19] clocksource: sh_cmt: Drop support for legacy platform data Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 03/19] clocksource: sh_cmt: Replace global spinlock with a per-device spinlock Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 04/19] clocksource: sh_tmu: Drop support for legacy platform data Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 05/19] clocksource: sh_tmu: Replace global spinlock with a per-device spinlock Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 06/19] clocksource: sh_mtu2: Drop support for legacy platform data Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 07/19] clocksource: sh_mtu2: Replace global spinlock with a per-device spinlock Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 08/19] clocksource: shmobile: Remove unused sh_timer_config members Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 09/19] clocksource: sh_cmt: Add DT support Laurent Pinchart
2014-07-04 13:15   ` Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 10/19] clocksource: sh_tmu: " Laurent Pinchart
2014-06-17  1:11   ` Simon Horman [this message]
2014-06-16 15:07 ` [PATCH v4 11/19] clocksource: sh_mtu2: " Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 12/19] ARM: shmobile: r8a7790: Add CMT devices to DT Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 13/19] ARM: shmobile: r8a7791: " Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 14/19] ARM: shmobile: r8a7779: Add TMU " Laurent Pinchart
2014-06-17  1:12   ` Simon Horman
2014-06-16 15:07 ` [PATCH v4 15/19] ARM: shmobile: r7s72100: Add MTU2 device " Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 16/19] ARM: shmobile: lager-reference: Enable CMT0 in device tree Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 17/19] ARM: shmobile: koelsch-reference: " Laurent Pinchart
2014-06-16 15:07 ` [PATCH v4 18/19] ARM: shmobile: marzen-reference: Enable TMU0 " Laurent Pinchart
2014-06-17  1:14   ` Simon Horman
2014-06-16 15:07 ` [PATCH v4 19/19] ARM: shmobile: genmai-reference: Enable MTU2 " Laurent Pinchart
2014-07-02 14:23 ` [GIT PULL FOR v3.17] Renesas CMT, MTU2 and TMU timers DT support Laurent Pinchart
2014-07-04 13:53   ` [GIT PULL v2 " Laurent Pinchart
2014-07-09  9:59     ` Laurent Pinchart
2014-07-13  9:55       ` Simon Horman
2014-07-13 13:00         ` Laurent Pinchart
2014-07-13 14:42           ` Daniel Lezcano
2014-07-13 20:39             ` Simon Horman
2014-07-14 21:54               ` Daniel Lezcano
2014-07-15  9:09                 ` Simon Horman
2014-07-14  9:06             ` Laurent Pinchart
2014-07-14 10:20               ` Daniel Lezcano

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=20140617011154.GA32454@verge.net.au \
    --to=horms@verge.net.au \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).