All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/19] Renesas CMT, MTU2 and TMU timers DT support
@ 2014-06-14 16:23 ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

This patch set adds DT bindings to the Renesas CMT, MTU2 and TMU timers.
Patches 02/19 to 13/19, 16/19 and 17/19 have already been posted in the
previous version of this series. Patches 14/19, 15/19, 18/19 and 19/19 are
new.

Compared to v2 I've rebased the patches on top of Simon's latest devel branch.

Compared to v1 I've dropped the channel subnodes from the CMT DT bindings and
just use a channels mask, as I don't need to specify per-channel properties.
I'm slightly uncertain about this change though, as I can't easily predict
whether per-channel properties would be needed later for new hardware. It
won't be difficult to reintroduce channel subnodes then, so I'd rather not
clutter the DT bindings with channel subnodes now. Please feel free to
disagree.

The first 11 patches should go through the timers tree while the last 8
patches should go through the Renesas SoC tree. Patches 12/19 to 15/19 have
no build time or run time dependency on the drivers changes. Patches 16/19 to
19/19 may have a run time dependency on the drivers changes depending on the
kernel configuration. Patches 16/19 and 17/19, for instance, require the
driver changes only when architected timer support isn't enabled in the
kernel.

Laurent Pinchart (19):
  clocksource: sh_tmu: Fix channel IRQ retrieval in legacy case
  clocksource: sh_cmt: Drop support for legacy platform data
  clocksource: sh_cmt: Replace global spinlock with a per-device
    spinlock
  clocksource: sh_tmu: Drop support for legacy platform data
  clocksource: sh_tmu: Replace global spinlock with a per-device
    spinlock
  clocksource: sh_mtu2: Drop support for legacy platform data
  clocksource: sh_mtu2: Replace global spinlock with a per-device
    spinlock
  clocksource: shmobile: Remove unused sh_timer_config members
  clocksource: sh_cmt: Add DT support
  clocksource: sh_tmu: Add DT support
  clocksource: sh_mtu2: Add DT support
  ARM: shmobile: r8a7790: Add CMT devices to DT
  ARM: shmobile: r8a7791: Add CMT devices to DT
  ARM: shmobile: r8a7779: Add TMU devices to DT
  ARM: shmobile: r7s72100: Add MTU2 device to DT
  ARM: shmobile: lager-reference: Enable CMT0 in device tree
  ARM: shmobile: koelsch-reference: Enable CMT0 in device tree
  ARM: shmobile: marzen-reference: Enable TMU0 in device tree
  ARM: shmobile: genmai-reference: Enable MTU2 in device tree

 .../devicetree/bindings/timer/renesas,cmt.txt      |  49 +++++
 .../devicetree/bindings/timer/renesas,mtu2.txt     |  40 ++++
 .../devicetree/bindings/timer/renesas,tmu.txt      |  40 ++++
 arch/arm/boot/dts/r7s72100-genmai.dts              |   4 +
 arch/arm/boot/dts/r7s72100.dtsi                    |  10 +
 arch/arm/boot/dts/r8a7779-marzen.dts               |   4 +
 arch/arm/boot/dts/r8a7779.dtsi                     |  42 ++++
 arch/arm/boot/dts/r8a7790-lager.dts                |   4 +
 arch/arm/boot/dts/r8a7790.dtsi                     |  34 +++
 arch/arm/boot/dts/r8a7791-koelsch.dts              |   4 +
 arch/arm/boot/dts/r8a7791.dtsi                     |  34 +++
 arch/arm/mach-shmobile/board-genmai-reference.c    |  16 --
 arch/arm/mach-shmobile/board-genmai.c              |  14 +-
 arch/arm/mach-shmobile/board-koelsch-reference.c   |   2 -
 arch/arm/mach-shmobile/board-lager-reference.c     |   2 -
 arch/arm/mach-shmobile/board-marzen-reference.c    |  10 -
 arch/arm/mach-shmobile/include/mach/r7s72100.h     |   1 -
 arch/arm/mach-shmobile/include/mach/r8a7779.h      |   1 -
 arch/arm/mach-shmobile/include/mach/r8a7790.h      |   1 -
 arch/arm/mach-shmobile/include/mach/r8a7791.h      |   1 -
 arch/arm/mach-shmobile/setup-r7s72100.c            |  21 --
 arch/arm/mach-shmobile/setup-r8a7779.c             |  17 +-
 arch/arm/mach-shmobile/setup-r8a7790.c             |   7 +-
 arch/arm/mach-shmobile/setup-r8a7791.c             |   7 +-
 drivers/clocksource/sh_cmt.c                       | 233 ++++++++-------------
 drivers/clocksource/sh_mtu2.c                      | 146 ++++---------
 drivers/clocksource/sh_tmu.c                       | 125 +++++------
 include/linux/sh_timer.h                           |   5 -
 28 files changed, 467 insertions(+), 407 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,cmt.txt
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,mtu2.txt
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,tmu.txt

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 00/19] Renesas CMT, MTU2 and TMU timers DT support
@ 2014-06-14 16:23 ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

This patch set adds DT bindings to the Renesas CMT, MTU2 and TMU timers.
Patches 02/19 to 13/19, 16/19 and 17/19 have already been posted in the
previous version of this series. Patches 14/19, 15/19, 18/19 and 19/19 are
new.

Compared to v2 I've rebased the patches on top of Simon's latest devel branch.

Compared to v1 I've dropped the channel subnodes from the CMT DT bindings and
just use a channels mask, as I don't need to specify per-channel properties.
I'm slightly uncertain about this change though, as I can't easily predict
whether per-channel properties would be needed later for new hardware. It
won't be difficult to reintroduce channel subnodes then, so I'd rather not
clutter the DT bindings with channel subnodes now. Please feel free to
disagree.

The first 11 patches should go through the timers tree while the last 8
patches should go through the Renesas SoC tree. Patches 12/19 to 15/19 have
no build time or run time dependency on the drivers changes. Patches 16/19 to
19/19 may have a run time dependency on the drivers changes depending on the
kernel configuration. Patches 16/19 and 17/19, for instance, require the
driver changes only when architected timer support isn't enabled in the
kernel.

Laurent Pinchart (19):
  clocksource: sh_tmu: Fix channel IRQ retrieval in legacy case
  clocksource: sh_cmt: Drop support for legacy platform data
  clocksource: sh_cmt: Replace global spinlock with a per-device
    spinlock
  clocksource: sh_tmu: Drop support for legacy platform data
  clocksource: sh_tmu: Replace global spinlock with a per-device
    spinlock
  clocksource: sh_mtu2: Drop support for legacy platform data
  clocksource: sh_mtu2: Replace global spinlock with a per-device
    spinlock
  clocksource: shmobile: Remove unused sh_timer_config members
  clocksource: sh_cmt: Add DT support
  clocksource: sh_tmu: Add DT support
  clocksource: sh_mtu2: Add DT support
  ARM: shmobile: r8a7790: Add CMT devices to DT
  ARM: shmobile: r8a7791: Add CMT devices to DT
  ARM: shmobile: r8a7779: Add TMU devices to DT
  ARM: shmobile: r7s72100: Add MTU2 device to DT
  ARM: shmobile: lager-reference: Enable CMT0 in device tree
  ARM: shmobile: koelsch-reference: Enable CMT0 in device tree
  ARM: shmobile: marzen-reference: Enable TMU0 in device tree
  ARM: shmobile: genmai-reference: Enable MTU2 in device tree

 .../devicetree/bindings/timer/renesas,cmt.txt      |  49 +++++
 .../devicetree/bindings/timer/renesas,mtu2.txt     |  40 ++++
 .../devicetree/bindings/timer/renesas,tmu.txt      |  40 ++++
 arch/arm/boot/dts/r7s72100-genmai.dts              |   4 +
 arch/arm/boot/dts/r7s72100.dtsi                    |  10 +
 arch/arm/boot/dts/r8a7779-marzen.dts               |   4 +
 arch/arm/boot/dts/r8a7779.dtsi                     |  42 ++++
 arch/arm/boot/dts/r8a7790-lager.dts                |   4 +
 arch/arm/boot/dts/r8a7790.dtsi                     |  34 +++
 arch/arm/boot/dts/r8a7791-koelsch.dts              |   4 +
 arch/arm/boot/dts/r8a7791.dtsi                     |  34 +++
 arch/arm/mach-shmobile/board-genmai-reference.c    |  16 --
 arch/arm/mach-shmobile/board-genmai.c              |  14 +-
 arch/arm/mach-shmobile/board-koelsch-reference.c   |   2 -
 arch/arm/mach-shmobile/board-lager-reference.c     |   2 -
 arch/arm/mach-shmobile/board-marzen-reference.c    |  10 -
 arch/arm/mach-shmobile/include/mach/r7s72100.h     |   1 -
 arch/arm/mach-shmobile/include/mach/r8a7779.h      |   1 -
 arch/arm/mach-shmobile/include/mach/r8a7790.h      |   1 -
 arch/arm/mach-shmobile/include/mach/r8a7791.h      |   1 -
 arch/arm/mach-shmobile/setup-r7s72100.c            |  21 --
 arch/arm/mach-shmobile/setup-r8a7779.c             |  17 +-
 arch/arm/mach-shmobile/setup-r8a7790.c             |   7 +-
 arch/arm/mach-shmobile/setup-r8a7791.c             |   7 +-
 drivers/clocksource/sh_cmt.c                       | 233 ++++++++-------------
 drivers/clocksource/sh_mtu2.c                      | 146 ++++---------
 drivers/clocksource/sh_tmu.c                       | 125 +++++------
 include/linux/sh_timer.h                           |   5 -
 28 files changed, 467 insertions(+), 407 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,cmt.txt
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,mtu2.txt
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,tmu.txt

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 01/19] clocksource: sh_tmu: Fix channel IRQ retrieval in legacy case
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

In the legacy platform data case each TMU platform device handles a
single channel with a single IRQ for the platform device. Retrieve the
IRQ using the logical channel number instead of the hardware channel
number.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/clocksource/sh_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 4ba2c0f..ec34095 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -498,7 +498,7 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, unsigned int index,
 			ch->base = tmu->mapbase + 8 + ch->index * 12;
 	}
 
-	ch->irq = platform_get_irq(tmu->pdev, ch->index);
+	ch->irq = platform_get_irq(tmu->pdev, index);
 	if (ch->irq < 0) {
 		dev_err(&tmu->pdev->dev, "ch%u: failed to get irq\n",
 			ch->index);
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 01/19] clocksource: sh_tmu: Fix channel IRQ retrieval in legacy case
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

In the legacy platform data case each TMU platform device handles a
single channel with a single IRQ for the platform device. Retrieve the
IRQ using the logical channel number instead of the hardware channel
number.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/clocksource/sh_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 4ba2c0f..ec34095 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -498,7 +498,7 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, unsigned int index,
 			ch->base = tmu->mapbase + 8 + ch->index * 12;
 	}
 
-	ch->irq = platform_get_irq(tmu->pdev, ch->index);
+	ch->irq = platform_get_irq(tmu->pdev, index);
 	if (ch->irq < 0) {
 		dev_err(&tmu->pdev->dev, "ch%u: failed to get irq\n",
 			ch->index);
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 02/19] clocksource: sh_cmt: Drop support for legacy platform data
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Now that all platforms have switched to the new-style platform data,
drop support for the legacy version.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/clocksource/sh_cmt.c | 172 ++++++++++---------------------------------
 1 file changed, 40 insertions(+), 132 deletions(-)

diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index bc8d025..ff1a059 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -114,9 +114,7 @@ struct sh_cmt_device {
 	struct platform_device *pdev;
 
 	const struct sh_cmt_info *info;
-	bool legacy;
 
-	void __iomem *mapbase_ch;
 	void __iomem *mapbase;
 	struct clk *clk;
 
@@ -792,7 +790,7 @@ static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch,
 	int irq;
 	int ret;
 
-	irq = platform_get_irq(ch->cmt->pdev, ch->cmt->legacy ? 0 : ch->index);
+	irq = platform_get_irq(ch->cmt->pdev, ch->index);
 	if (irq < 0) {
 		dev_err(&ch->cmt->pdev->dev, "ch%u: failed to get irq\n",
 			ch->index);
@@ -863,33 +861,26 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index,
 	 * Compute the address of the channel control register block. For the
 	 * timers with a per-channel start/stop register, compute its address
 	 * as well.
-	 *
-	 * For legacy configuration the address has been mapped explicitly.
 	 */
-	if (cmt->legacy) {
-		ch->ioctrl = cmt->mapbase_ch;
-	} else {
-		switch (cmt->info->model) {
-		case SH_CMT_16BIT:
-			ch->ioctrl = cmt->mapbase + 2 + ch->hwidx * 6;
-			break;
-		case SH_CMT_32BIT:
-		case SH_CMT_48BIT:
-			ch->ioctrl = cmt->mapbase + 0x10 + ch->hwidx * 0x10;
-			break;
-		case SH_CMT_32BIT_FAST:
-			/*
-			 * The 32-bit "fast" timer has a single channel at hwidx
-			 * 5 but is located at offset 0x40 instead of 0x60 for
-			 * some reason.
-			 */
-			ch->ioctrl = cmt->mapbase + 0x40;
-			break;
-		case SH_CMT_48BIT_GEN2:
-			ch->iostart = cmt->mapbase + ch->hwidx * 0x100;
-			ch->ioctrl = ch->iostart + 0x10;
-			break;
-		}
+	switch (cmt->info->model) {
+	case SH_CMT_16BIT:
+		ch->ioctrl = cmt->mapbase + 2 + ch->hwidx * 6;
+		break;
+	case SH_CMT_32BIT:
+	case SH_CMT_48BIT:
+		ch->ioctrl = cmt->mapbase + 0x10 + ch->hwidx * 0x10;
+		break;
+	case SH_CMT_32BIT_FAST:
+		/*
+		 * The 32-bit "fast" timer has a single channel at hwidx 5 but
+		 * is located at offset 0x40 instead of 0x60 for some reason.
+		 */
+		ch->ioctrl = cmt->mapbase + 0x40;
+		break;
+	case SH_CMT_48BIT_GEN2:
+		ch->iostart = cmt->mapbase + ch->hwidx * 0x100;
+		ch->ioctrl = ch->iostart + 0x10;
+		break;
 	}
 
 	if (cmt->info->width = (sizeof(ch->max_match_value) * 8))
@@ -900,12 +891,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index,
 	ch->match_value = ch->max_match_value;
 	raw_spin_lock_init(&ch->lock);
 
-	if (cmt->legacy) {
-		ch->timer_bit = ch->hwidx;
-	} else {
-		ch->timer_bit = cmt->info->model = SH_CMT_48BIT_GEN2
-			      ? 0 : ch->hwidx;
-	}
+	ch->timer_bit = cmt->info->model = SH_CMT_48BIT_GEN2 ? 0 : ch->hwidx;
 
 	ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev),
 			      clockevent, clocksource);
@@ -938,60 +924,12 @@ static int sh_cmt_map_memory(struct sh_cmt_device *cmt)
 	return 0;
 }
 
-static int sh_cmt_map_memory_legacy(struct sh_cmt_device *cmt)
-{
-	struct sh_timer_config *cfg = cmt->pdev->dev.platform_data;
-	struct resource *res, *res2;
-
-	/* map memory, let mapbase_ch point to our channel */
-	res = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&cmt->pdev->dev, "failed to get I/O memory\n");
-		return -ENXIO;
-	}
-
-	cmt->mapbase_ch = ioremap_nocache(res->start, resource_size(res));
-	if (cmt->mapbase_ch = NULL) {
-		dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n");
-		return -ENXIO;
-	}
-
-	/* optional resource for the shared timer start/stop register */
-	res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1);
-
-	/* map second resource for CMSTR */
-	cmt->mapbase = ioremap_nocache(res2 ? res2->start :
-				       res->start - cfg->channel_offset,
-				       res2 ? resource_size(res2) : 2);
-	if (cmt->mapbase = NULL) {
-		dev_err(&cmt->pdev->dev, "failed to remap I/O second memory\n");
-		iounmap(cmt->mapbase_ch);
-		return -ENXIO;
-	}
-
-	/* identify the model based on the resources */
-	if (resource_size(res) = 6)
-		cmt->info = &sh_cmt_info[SH_CMT_16BIT];
-	else if (res2 && (resource_size(res2) = 4))
-		cmt->info = &sh_cmt_info[SH_CMT_48BIT_GEN2];
-	else
-		cmt->info = &sh_cmt_info[SH_CMT_32BIT];
-
-	return 0;
-}
-
-static void sh_cmt_unmap_memory(struct sh_cmt_device *cmt)
-{
-	iounmap(cmt->mapbase);
-	if (cmt->mapbase_ch)
-		iounmap(cmt->mapbase_ch);
-}
-
 static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 {
 	struct sh_timer_config *cfg = pdev->dev.platform_data;
 	const struct platform_device_id *id = pdev->id_entry;
-	unsigned int hw_channels;
+	unsigned int mask;
+	unsigned int i;
 	int ret;
 
 	memset(cmt, 0, sizeof(*cmt));
@@ -1003,10 +941,9 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 	}
 
 	cmt->info = (const struct sh_cmt_info *)id->driver_data;
-	cmt->legacy = cmt->info ? false : true;
 
 	/* Get hold of clock. */
-	cmt->clk = clk_get(&cmt->pdev->dev, cmt->legacy ? "cmt_fck" : "fck");
+	cmt->clk = clk_get(&cmt->pdev->dev, "fck");
 	if (IS_ERR(cmt->clk)) {
 		dev_err(&cmt->pdev->dev, "cannot get clock\n");
 		return PTR_ERR(cmt->clk);
@@ -1016,27 +953,13 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 	if (ret < 0)
 		goto err_clk_put;
 
-	/*
-	 * Map the memory resource(s). We need to support both the legacy
-	 * platform device configuration (with one device per channel) and the
-	 * new version (with multiple channels per device).
-	 */
-	if (cmt->legacy)
-		ret = sh_cmt_map_memory_legacy(cmt);
-	else
-		ret = sh_cmt_map_memory(cmt);
-
+	/* Map the memory resource(s). */
+	ret = sh_cmt_map_memory(cmt);
 	if (ret < 0)
 		goto err_clk_unprepare;
 
 	/* Allocate and setup the channels. */
-	if (cmt->legacy) {
-		cmt->num_channels = 1;
-		hw_channels = 0;
-	} else {
-		cmt->num_channels = hweight8(cfg->channels_mask);
-		hw_channels = cfg->channels_mask;
-	}
+	cmt->num_channels = hweight8(cfg->channels_mask);
 
 	cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels),
 				GFP_KERNEL);
@@ -1045,35 +968,21 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 		goto err_unmap;
 	}
 
-	if (cmt->legacy) {
-		ret = sh_cmt_setup_channel(&cmt->channels[0],
-					   cfg->timer_bit, cfg->timer_bit,
-					   cfg->clockevent_rating != 0,
-					   cfg->clocksource_rating != 0, cmt);
+	/*
+	 * Use the first channel as a clock event device and the second channel
+	 * as a clock source. If only one channel is available use it for both.
+	 */
+	for (i = 0, mask = cfg->channels_mask; i < cmt->num_channels; ++i) {
+		unsigned int hwidx = ffs(mask) - 1;
+		bool clocksource = i = 1 || cmt->num_channels = 1;
+		bool clockevent = i = 0;
+
+		ret = sh_cmt_setup_channel(&cmt->channels[i], i, hwidx,
+					   clockevent, clocksource, cmt);
 		if (ret < 0)
 			goto err_unmap;
-	} else {
-		unsigned int mask = hw_channels;
-		unsigned int i;
 
-		/*
-		 * Use the first channel as a clock event device and the second
-		 * channel as a clock source. If only one channel is available
-		 * use it for both.
-		 */
-		for (i = 0; i < cmt->num_channels; ++i) {
-			unsigned int hwidx = ffs(mask) - 1;
-			bool clocksource = i = 1 || cmt->num_channels = 1;
-			bool clockevent = i = 0;
-
-			ret = sh_cmt_setup_channel(&cmt->channels[i], i, hwidx,
-						   clockevent, clocksource,
-						   cmt);
-			if (ret < 0)
-				goto err_unmap;
-
-			mask &= ~(1 << hwidx);
-		}
+		mask &= ~(1 << hwidx);
 	}
 
 	platform_set_drvdata(pdev, cmt);
@@ -1082,7 +991,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 
 err_unmap:
 	kfree(cmt->channels);
-	sh_cmt_unmap_memory(cmt);
+	iounmap(cmt->mapbase);
 err_clk_unprepare:
 	clk_unprepare(cmt->clk);
 err_clk_put:
@@ -1135,7 +1044,6 @@ static int sh_cmt_remove(struct platform_device *pdev)
 }
 
 static const struct platform_device_id sh_cmt_id_table[] = {
-	{ "sh_cmt", 0 },
 	{ "sh-cmt-16", (kernel_ulong_t)&sh_cmt_info[SH_CMT_16BIT] },
 	{ "sh-cmt-32", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT] },
 	{ "sh-cmt-32-fast", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT_FAST] },
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 02/19] clocksource: sh_cmt: Drop support for legacy platform data
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Now that all platforms have switched to the new-style platform data,
drop support for the legacy version.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/clocksource/sh_cmt.c | 172 ++++++++++---------------------------------
 1 file changed, 40 insertions(+), 132 deletions(-)

diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index bc8d025..ff1a059 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -114,9 +114,7 @@ struct sh_cmt_device {
 	struct platform_device *pdev;
 
 	const struct sh_cmt_info *info;
-	bool legacy;
 
-	void __iomem *mapbase_ch;
 	void __iomem *mapbase;
 	struct clk *clk;
 
@@ -792,7 +790,7 @@ static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch,
 	int irq;
 	int ret;
 
-	irq = platform_get_irq(ch->cmt->pdev, ch->cmt->legacy ? 0 : ch->index);
+	irq = platform_get_irq(ch->cmt->pdev, ch->index);
 	if (irq < 0) {
 		dev_err(&ch->cmt->pdev->dev, "ch%u: failed to get irq\n",
 			ch->index);
@@ -863,33 +861,26 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index,
 	 * Compute the address of the channel control register block. For the
 	 * timers with a per-channel start/stop register, compute its address
 	 * as well.
-	 *
-	 * For legacy configuration the address has been mapped explicitly.
 	 */
-	if (cmt->legacy) {
-		ch->ioctrl = cmt->mapbase_ch;
-	} else {
-		switch (cmt->info->model) {
-		case SH_CMT_16BIT:
-			ch->ioctrl = cmt->mapbase + 2 + ch->hwidx * 6;
-			break;
-		case SH_CMT_32BIT:
-		case SH_CMT_48BIT:
-			ch->ioctrl = cmt->mapbase + 0x10 + ch->hwidx * 0x10;
-			break;
-		case SH_CMT_32BIT_FAST:
-			/*
-			 * The 32-bit "fast" timer has a single channel at hwidx
-			 * 5 but is located at offset 0x40 instead of 0x60 for
-			 * some reason.
-			 */
-			ch->ioctrl = cmt->mapbase + 0x40;
-			break;
-		case SH_CMT_48BIT_GEN2:
-			ch->iostart = cmt->mapbase + ch->hwidx * 0x100;
-			ch->ioctrl = ch->iostart + 0x10;
-			break;
-		}
+	switch (cmt->info->model) {
+	case SH_CMT_16BIT:
+		ch->ioctrl = cmt->mapbase + 2 + ch->hwidx * 6;
+		break;
+	case SH_CMT_32BIT:
+	case SH_CMT_48BIT:
+		ch->ioctrl = cmt->mapbase + 0x10 + ch->hwidx * 0x10;
+		break;
+	case SH_CMT_32BIT_FAST:
+		/*
+		 * The 32-bit "fast" timer has a single channel at hwidx 5 but
+		 * is located at offset 0x40 instead of 0x60 for some reason.
+		 */
+		ch->ioctrl = cmt->mapbase + 0x40;
+		break;
+	case SH_CMT_48BIT_GEN2:
+		ch->iostart = cmt->mapbase + ch->hwidx * 0x100;
+		ch->ioctrl = ch->iostart + 0x10;
+		break;
 	}
 
 	if (cmt->info->width == (sizeof(ch->max_match_value) * 8))
@@ -900,12 +891,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index,
 	ch->match_value = ch->max_match_value;
 	raw_spin_lock_init(&ch->lock);
 
-	if (cmt->legacy) {
-		ch->timer_bit = ch->hwidx;
-	} else {
-		ch->timer_bit = cmt->info->model == SH_CMT_48BIT_GEN2
-			      ? 0 : ch->hwidx;
-	}
+	ch->timer_bit = cmt->info->model == SH_CMT_48BIT_GEN2 ? 0 : ch->hwidx;
 
 	ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev),
 			      clockevent, clocksource);
@@ -938,60 +924,12 @@ static int sh_cmt_map_memory(struct sh_cmt_device *cmt)
 	return 0;
 }
 
-static int sh_cmt_map_memory_legacy(struct sh_cmt_device *cmt)
-{
-	struct sh_timer_config *cfg = cmt->pdev->dev.platform_data;
-	struct resource *res, *res2;
-
-	/* map memory, let mapbase_ch point to our channel */
-	res = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&cmt->pdev->dev, "failed to get I/O memory\n");
-		return -ENXIO;
-	}
-
-	cmt->mapbase_ch = ioremap_nocache(res->start, resource_size(res));
-	if (cmt->mapbase_ch == NULL) {
-		dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n");
-		return -ENXIO;
-	}
-
-	/* optional resource for the shared timer start/stop register */
-	res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1);
-
-	/* map second resource for CMSTR */
-	cmt->mapbase = ioremap_nocache(res2 ? res2->start :
-				       res->start - cfg->channel_offset,
-				       res2 ? resource_size(res2) : 2);
-	if (cmt->mapbase == NULL) {
-		dev_err(&cmt->pdev->dev, "failed to remap I/O second memory\n");
-		iounmap(cmt->mapbase_ch);
-		return -ENXIO;
-	}
-
-	/* identify the model based on the resources */
-	if (resource_size(res) == 6)
-		cmt->info = &sh_cmt_info[SH_CMT_16BIT];
-	else if (res2 && (resource_size(res2) == 4))
-		cmt->info = &sh_cmt_info[SH_CMT_48BIT_GEN2];
-	else
-		cmt->info = &sh_cmt_info[SH_CMT_32BIT];
-
-	return 0;
-}
-
-static void sh_cmt_unmap_memory(struct sh_cmt_device *cmt)
-{
-	iounmap(cmt->mapbase);
-	if (cmt->mapbase_ch)
-		iounmap(cmt->mapbase_ch);
-}
-
 static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 {
 	struct sh_timer_config *cfg = pdev->dev.platform_data;
 	const struct platform_device_id *id = pdev->id_entry;
-	unsigned int hw_channels;
+	unsigned int mask;
+	unsigned int i;
 	int ret;
 
 	memset(cmt, 0, sizeof(*cmt));
@@ -1003,10 +941,9 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 	}
 
 	cmt->info = (const struct sh_cmt_info *)id->driver_data;
-	cmt->legacy = cmt->info ? false : true;
 
 	/* Get hold of clock. */
-	cmt->clk = clk_get(&cmt->pdev->dev, cmt->legacy ? "cmt_fck" : "fck");
+	cmt->clk = clk_get(&cmt->pdev->dev, "fck");
 	if (IS_ERR(cmt->clk)) {
 		dev_err(&cmt->pdev->dev, "cannot get clock\n");
 		return PTR_ERR(cmt->clk);
@@ -1016,27 +953,13 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 	if (ret < 0)
 		goto err_clk_put;
 
-	/*
-	 * Map the memory resource(s). We need to support both the legacy
-	 * platform device configuration (with one device per channel) and the
-	 * new version (with multiple channels per device).
-	 */
-	if (cmt->legacy)
-		ret = sh_cmt_map_memory_legacy(cmt);
-	else
-		ret = sh_cmt_map_memory(cmt);
-
+	/* Map the memory resource(s). */
+	ret = sh_cmt_map_memory(cmt);
 	if (ret < 0)
 		goto err_clk_unprepare;
 
 	/* Allocate and setup the channels. */
-	if (cmt->legacy) {
-		cmt->num_channels = 1;
-		hw_channels = 0;
-	} else {
-		cmt->num_channels = hweight8(cfg->channels_mask);
-		hw_channels = cfg->channels_mask;
-	}
+	cmt->num_channels = hweight8(cfg->channels_mask);
 
 	cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels),
 				GFP_KERNEL);
@@ -1045,35 +968,21 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 		goto err_unmap;
 	}
 
-	if (cmt->legacy) {
-		ret = sh_cmt_setup_channel(&cmt->channels[0],
-					   cfg->timer_bit, cfg->timer_bit,
-					   cfg->clockevent_rating != 0,
-					   cfg->clocksource_rating != 0, cmt);
+	/*
+	 * Use the first channel as a clock event device and the second channel
+	 * as a clock source. If only one channel is available use it for both.
+	 */
+	for (i = 0, mask = cfg->channels_mask; i < cmt->num_channels; ++i) {
+		unsigned int hwidx = ffs(mask) - 1;
+		bool clocksource = i == 1 || cmt->num_channels == 1;
+		bool clockevent = i == 0;
+
+		ret = sh_cmt_setup_channel(&cmt->channels[i], i, hwidx,
+					   clockevent, clocksource, cmt);
 		if (ret < 0)
 			goto err_unmap;
-	} else {
-		unsigned int mask = hw_channels;
-		unsigned int i;
 
-		/*
-		 * Use the first channel as a clock event device and the second
-		 * channel as a clock source. If only one channel is available
-		 * use it for both.
-		 */
-		for (i = 0; i < cmt->num_channels; ++i) {
-			unsigned int hwidx = ffs(mask) - 1;
-			bool clocksource = i == 1 || cmt->num_channels == 1;
-			bool clockevent = i == 0;
-
-			ret = sh_cmt_setup_channel(&cmt->channels[i], i, hwidx,
-						   clockevent, clocksource,
-						   cmt);
-			if (ret < 0)
-				goto err_unmap;
-
-			mask &= ~(1 << hwidx);
-		}
+		mask &= ~(1 << hwidx);
 	}
 
 	platform_set_drvdata(pdev, cmt);
@@ -1082,7 +991,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 
 err_unmap:
 	kfree(cmt->channels);
-	sh_cmt_unmap_memory(cmt);
+	iounmap(cmt->mapbase);
 err_clk_unprepare:
 	clk_unprepare(cmt->clk);
 err_clk_put:
@@ -1135,7 +1044,6 @@ static int sh_cmt_remove(struct platform_device *pdev)
 }
 
 static const struct platform_device_id sh_cmt_id_table[] = {
-	{ "sh_cmt", 0 },
 	{ "sh-cmt-16", (kernel_ulong_t)&sh_cmt_info[SH_CMT_16BIT] },
 	{ "sh-cmt-32", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT] },
 	{ "sh-cmt-32-fast", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT_FAST] },
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 03/19] clocksource: sh_cmt: Replace global spinlock with a per-device spinlock
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

The global spinlock is used to protect the shared start/stop register.
Now that all CMT channels are handled by a single device instance, use a
per-device spinlock.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/clocksource/sh_cmt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index ff1a059..4d00e4b 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -118,6 +118,8 @@ struct sh_cmt_device {
 	void __iomem *mapbase;
 	struct clk *clk;
 
+	raw_spinlock_t lock; /* Protect the shared start/stop register */
+
 	struct sh_cmt_channel *channels;
 	unsigned int num_channels;
 
@@ -299,14 +301,12 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch,
 	return v2;
 }
 
-static DEFINE_RAW_SPINLOCK(sh_cmt_lock);
-
 static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start)
 {
 	unsigned long flags, value;
 
 	/* start stop register shared by multiple timer channels */
-	raw_spin_lock_irqsave(&sh_cmt_lock, flags);
+	raw_spin_lock_irqsave(&ch->cmt->lock, flags);
 	value = sh_cmt_read_cmstr(ch);
 
 	if (start)
@@ -315,7 +315,7 @@ static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start)
 		value &= ~(1 << ch->timer_bit);
 
 	sh_cmt_write_cmstr(ch, value);
-	raw_spin_unlock_irqrestore(&sh_cmt_lock, flags);
+	raw_spin_unlock_irqrestore(&ch->cmt->lock, flags);
 }
 
 static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate)
@@ -934,6 +934,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 
 	memset(cmt, 0, sizeof(*cmt));
 	cmt->pdev = pdev;
+	raw_spin_lock_init(&cmt->lock);
 
 	if (!cfg) {
 		dev_err(&cmt->pdev->dev, "missing platform data\n");
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 03/19] clocksource: sh_cmt: Replace global spinlock with a per-device spinlock
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

The global spinlock is used to protect the shared start/stop register.
Now that all CMT channels are handled by a single device instance, use a
per-device spinlock.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/clocksource/sh_cmt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index ff1a059..4d00e4b 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -118,6 +118,8 @@ struct sh_cmt_device {
 	void __iomem *mapbase;
 	struct clk *clk;
 
+	raw_spinlock_t lock; /* Protect the shared start/stop register */
+
 	struct sh_cmt_channel *channels;
 	unsigned int num_channels;
 
@@ -299,14 +301,12 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch,
 	return v2;
 }
 
-static DEFINE_RAW_SPINLOCK(sh_cmt_lock);
-
 static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start)
 {
 	unsigned long flags, value;
 
 	/* start stop register shared by multiple timer channels */
-	raw_spin_lock_irqsave(&sh_cmt_lock, flags);
+	raw_spin_lock_irqsave(&ch->cmt->lock, flags);
 	value = sh_cmt_read_cmstr(ch);
 
 	if (start)
@@ -315,7 +315,7 @@ static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start)
 		value &= ~(1 << ch->timer_bit);
 
 	sh_cmt_write_cmstr(ch, value);
-	raw_spin_unlock_irqrestore(&sh_cmt_lock, flags);
+	raw_spin_unlock_irqrestore(&ch->cmt->lock, flags);
 }
 
 static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate)
@@ -934,6 +934,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 
 	memset(cmt, 0, sizeof(*cmt));
 	cmt->pdev = pdev;
+	raw_spin_lock_init(&cmt->lock);
 
 	if (!cfg) {
 		dev_err(&cmt->pdev->dev, "missing platform data\n");
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 04/19] clocksource: sh_tmu: Drop support for legacy platform data
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Now that all platforms have switched to the new-style platform data,
drop support for the legacy version.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/clocksource/sh_tmu.c | 82 ++++++++------------------------------------
 1 file changed, 15 insertions(+), 67 deletions(-)

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index ec34095..4363eb7 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -32,7 +32,6 @@
 #include <linux/spinlock.h>
 
 enum sh_tmu_model {
-	SH_TMU_LEGACY,
 	SH_TMU,
 	SH_TMU_SH3,
 };
@@ -91,8 +90,6 @@ static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr)
 
 	if (reg_nr = TSTR) {
 		switch (ch->tmu->model) {
-		case SH_TMU_LEGACY:
-			return ioread8(ch->tmu->mapbase);
 		case SH_TMU_SH3:
 			return ioread8(ch->tmu->mapbase + 2);
 		case SH_TMU:
@@ -115,8 +112,6 @@ static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr,
 
 	if (reg_nr = TSTR) {
 		switch (ch->tmu->model) {
-		case SH_TMU_LEGACY:
-			return iowrite8(value, ch->tmu->mapbase);
 		case SH_TMU_SH3:
 			return iowrite8(value, ch->tmu->mapbase + 2);
 		case SH_TMU:
@@ -476,27 +471,12 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, unsigned int index,
 		return 0;
 
 	ch->tmu = tmu;
+	ch->index = index;
 
-	if (tmu->model = SH_TMU_LEGACY) {
-		struct sh_timer_config *cfg = tmu->pdev->dev.platform_data;
-
-		/*
-		 * The SH3 variant (SH770x, SH7705, SH7710 and SH7720) maps
-		 * channel registers blocks at base + 2 + 12 * index, while all
-		 * other variants map them at base + 4 + 12 * index. We can
-		 * compute the index by just dividing by 12, the 2 bytes or 4
-		 * bytes offset being hidden by the integer division.
-		 */
-		ch->index = cfg->channel_offset / 12;
-		ch->base = tmu->mapbase + cfg->channel_offset;
-	} else {
-		ch->index = index;
-
-		if (tmu->model = SH_TMU_SH3)
-			ch->base = tmu->mapbase + 4 + ch->index * 12;
-		else
-			ch->base = tmu->mapbase + 8 + ch->index * 12;
-	}
+	if (tmu->model = SH_TMU_SH3)
+		ch->base = tmu->mapbase + 4 + ch->index * 12;
+	else
+		ch->base = tmu->mapbase + 8 + ch->index * 12;
 
 	ch->irq = platform_get_irq(tmu->pdev, index);
 	if (ch->irq < 0) {
@@ -526,28 +506,9 @@ static int sh_tmu_map_memory(struct sh_tmu_device *tmu)
 	if (tmu->mapbase = NULL)
 		return -ENXIO;
 
-	/*
-	 * In legacy platform device configuration (with one device per channel)
-	 * the resource points to the channel base address.
-	 */
-	if (tmu->model = SH_TMU_LEGACY) {
-		struct sh_timer_config *cfg = tmu->pdev->dev.platform_data;
-		tmu->mapbase -= cfg->channel_offset;
-	}
-
 	return 0;
 }
 
-static void sh_tmu_unmap_memory(struct sh_tmu_device *tmu)
-{
-	if (tmu->model = SH_TMU_LEGACY) {
-		struct sh_timer_config *cfg = tmu->pdev->dev.platform_data;
-		tmu->mapbase += cfg->channel_offset;
-	}
-
-	iounmap(tmu->mapbase);
-}
-
 static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 {
 	struct sh_timer_config *cfg = pdev->dev.platform_data;
@@ -564,8 +525,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 	tmu->model = id->driver_data;
 
 	/* Get hold of clock. */
-	tmu->clk = clk_get(&tmu->pdev->dev,
-			   tmu->model = SH_TMU_LEGACY ? "tmu_fck" : "fck");
+	tmu->clk = clk_get(&tmu->pdev->dev, "fck");
 	if (IS_ERR(tmu->clk)) {
 		dev_err(&tmu->pdev->dev, "cannot get clock\n");
 		return PTR_ERR(tmu->clk);
@@ -583,10 +543,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 	}
 
 	/* Allocate and setup the channels. */
-	if (tmu->model = SH_TMU_LEGACY)
-		tmu->num_channels = 1;
-	else
-		tmu->num_channels = hweight8(cfg->channels_mask);
+	tmu->num_channels = hweight8(cfg->channels_mask);
 
 	tmu->channels = kzalloc(sizeof(*tmu->channels) * tmu->num_channels,
 				GFP_KERNEL);
@@ -595,23 +552,15 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 		goto err_unmap;
 	}
 
-	if (tmu->model = SH_TMU_LEGACY) {
-		ret = sh_tmu_channel_setup(&tmu->channels[0], 0,
-					   cfg->clockevent_rating != 0,
-					   cfg->clocksource_rating != 0, tmu);
+	/*
+	 * Use the first channel as a clock event device and the second channel
+	 * as a clock source.
+	 */
+	for (i = 0; i < tmu->num_channels; ++i) {
+		ret = sh_tmu_channel_setup(&tmu->channels[i], i,
+					   i = 0, i = 1, tmu);
 		if (ret < 0)
 			goto err_unmap;
-	} else {
-		/*
-		 * Use the first channel as a clock event device and the second
-		 * channel as a clock source.
-		 */
-		for (i = 0; i < tmu->num_channels; ++i) {
-			ret = sh_tmu_channel_setup(&tmu->channels[i], i,
-						   i = 0, i = 1, tmu);
-			if (ret < 0)
-				goto err_unmap;
-		}
 	}
 
 	platform_set_drvdata(pdev, tmu);
@@ -620,7 +569,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 
 err_unmap:
 	kfree(tmu->channels);
-	sh_tmu_unmap_memory(tmu);
+	iounmap(tmu->mapbase);
 err_clk_unprepare:
 	clk_unprepare(tmu->clk);
 err_clk_put:
@@ -673,7 +622,6 @@ static int sh_tmu_remove(struct platform_device *pdev)
 }
 
 static const struct platform_device_id sh_tmu_id_table[] = {
-	{ "sh_tmu", SH_TMU_LEGACY },
 	{ "sh-tmu", SH_TMU },
 	{ "sh-tmu-sh3", SH_TMU_SH3 },
 	{ }
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 04/19] clocksource: sh_tmu: Drop support for legacy platform data
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Now that all platforms have switched to the new-style platform data,
drop support for the legacy version.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/clocksource/sh_tmu.c | 82 ++++++++------------------------------------
 1 file changed, 15 insertions(+), 67 deletions(-)

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index ec34095..4363eb7 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -32,7 +32,6 @@
 #include <linux/spinlock.h>
 
 enum sh_tmu_model {
-	SH_TMU_LEGACY,
 	SH_TMU,
 	SH_TMU_SH3,
 };
@@ -91,8 +90,6 @@ static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr)
 
 	if (reg_nr == TSTR) {
 		switch (ch->tmu->model) {
-		case SH_TMU_LEGACY:
-			return ioread8(ch->tmu->mapbase);
 		case SH_TMU_SH3:
 			return ioread8(ch->tmu->mapbase + 2);
 		case SH_TMU:
@@ -115,8 +112,6 @@ static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr,
 
 	if (reg_nr == TSTR) {
 		switch (ch->tmu->model) {
-		case SH_TMU_LEGACY:
-			return iowrite8(value, ch->tmu->mapbase);
 		case SH_TMU_SH3:
 			return iowrite8(value, ch->tmu->mapbase + 2);
 		case SH_TMU:
@@ -476,27 +471,12 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, unsigned int index,
 		return 0;
 
 	ch->tmu = tmu;
+	ch->index = index;
 
-	if (tmu->model == SH_TMU_LEGACY) {
-		struct sh_timer_config *cfg = tmu->pdev->dev.platform_data;
-
-		/*
-		 * The SH3 variant (SH770x, SH7705, SH7710 and SH7720) maps
-		 * channel registers blocks at base + 2 + 12 * index, while all
-		 * other variants map them at base + 4 + 12 * index. We can
-		 * compute the index by just dividing by 12, the 2 bytes or 4
-		 * bytes offset being hidden by the integer division.
-		 */
-		ch->index = cfg->channel_offset / 12;
-		ch->base = tmu->mapbase + cfg->channel_offset;
-	} else {
-		ch->index = index;
-
-		if (tmu->model == SH_TMU_SH3)
-			ch->base = tmu->mapbase + 4 + ch->index * 12;
-		else
-			ch->base = tmu->mapbase + 8 + ch->index * 12;
-	}
+	if (tmu->model == SH_TMU_SH3)
+		ch->base = tmu->mapbase + 4 + ch->index * 12;
+	else
+		ch->base = tmu->mapbase + 8 + ch->index * 12;
 
 	ch->irq = platform_get_irq(tmu->pdev, index);
 	if (ch->irq < 0) {
@@ -526,28 +506,9 @@ static int sh_tmu_map_memory(struct sh_tmu_device *tmu)
 	if (tmu->mapbase == NULL)
 		return -ENXIO;
 
-	/*
-	 * In legacy platform device configuration (with one device per channel)
-	 * the resource points to the channel base address.
-	 */
-	if (tmu->model == SH_TMU_LEGACY) {
-		struct sh_timer_config *cfg = tmu->pdev->dev.platform_data;
-		tmu->mapbase -= cfg->channel_offset;
-	}
-
 	return 0;
 }
 
-static void sh_tmu_unmap_memory(struct sh_tmu_device *tmu)
-{
-	if (tmu->model == SH_TMU_LEGACY) {
-		struct sh_timer_config *cfg = tmu->pdev->dev.platform_data;
-		tmu->mapbase += cfg->channel_offset;
-	}
-
-	iounmap(tmu->mapbase);
-}
-
 static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 {
 	struct sh_timer_config *cfg = pdev->dev.platform_data;
@@ -564,8 +525,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 	tmu->model = id->driver_data;
 
 	/* Get hold of clock. */
-	tmu->clk = clk_get(&tmu->pdev->dev,
-			   tmu->model == SH_TMU_LEGACY ? "tmu_fck" : "fck");
+	tmu->clk = clk_get(&tmu->pdev->dev, "fck");
 	if (IS_ERR(tmu->clk)) {
 		dev_err(&tmu->pdev->dev, "cannot get clock\n");
 		return PTR_ERR(tmu->clk);
@@ -583,10 +543,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 	}
 
 	/* Allocate and setup the channels. */
-	if (tmu->model == SH_TMU_LEGACY)
-		tmu->num_channels = 1;
-	else
-		tmu->num_channels = hweight8(cfg->channels_mask);
+	tmu->num_channels = hweight8(cfg->channels_mask);
 
 	tmu->channels = kzalloc(sizeof(*tmu->channels) * tmu->num_channels,
 				GFP_KERNEL);
@@ -595,23 +552,15 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 		goto err_unmap;
 	}
 
-	if (tmu->model == SH_TMU_LEGACY) {
-		ret = sh_tmu_channel_setup(&tmu->channels[0], 0,
-					   cfg->clockevent_rating != 0,
-					   cfg->clocksource_rating != 0, tmu);
+	/*
+	 * Use the first channel as a clock event device and the second channel
+	 * as a clock source.
+	 */
+	for (i = 0; i < tmu->num_channels; ++i) {
+		ret = sh_tmu_channel_setup(&tmu->channels[i], i,
+					   i == 0, i == 1, tmu);
 		if (ret < 0)
 			goto err_unmap;
-	} else {
-		/*
-		 * Use the first channel as a clock event device and the second
-		 * channel as a clock source.
-		 */
-		for (i = 0; i < tmu->num_channels; ++i) {
-			ret = sh_tmu_channel_setup(&tmu->channels[i], i,
-						   i == 0, i == 1, tmu);
-			if (ret < 0)
-				goto err_unmap;
-		}
 	}
 
 	platform_set_drvdata(pdev, tmu);
@@ -620,7 +569,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 
 err_unmap:
 	kfree(tmu->channels);
-	sh_tmu_unmap_memory(tmu);
+	iounmap(tmu->mapbase);
 err_clk_unprepare:
 	clk_unprepare(tmu->clk);
 err_clk_put:
@@ -673,7 +622,6 @@ static int sh_tmu_remove(struct platform_device *pdev)
 }
 
 static const struct platform_device_id sh_tmu_id_table[] = {
-	{ "sh_tmu", SH_TMU_LEGACY },
 	{ "sh-tmu", SH_TMU },
 	{ "sh-tmu-sh3", SH_TMU_SH3 },
 	{ }
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 05/19] clocksource: sh_tmu: Replace global spinlock with a per-device spinlock
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

The global spinlock is used to protect the shared start/stop register.
Now that all TMU channels are handled by a single device instance, use a
per-device spinlock.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/clocksource/sh_tmu.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 4363eb7..ef8fb0b 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -61,6 +61,8 @@ struct sh_tmu_device {
 
 	enum sh_tmu_model model;
 
+	raw_spinlock_t lock; /* Protect the shared start/stop register */
+
 	struct sh_tmu_channel *channels;
 	unsigned int num_channels;
 
@@ -68,8 +70,6 @@ struct sh_tmu_device {
 	bool has_clocksource;
 };
 
-static DEFINE_RAW_SPINLOCK(sh_tmu_lock);
-
 #define TSTR -1 /* shared register */
 #define TCOR  0 /* channel register */
 #define TCNT 1 /* channel register */
@@ -132,7 +132,7 @@ static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start)
 	unsigned long flags, value;
 
 	/* start stop register shared by multiple timer channels */
-	raw_spin_lock_irqsave(&sh_tmu_lock, flags);
+	raw_spin_lock_irqsave(&ch->tmu->lock, flags);
 	value = sh_tmu_read(ch, TSTR);
 
 	if (start)
@@ -141,7 +141,7 @@ static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start)
 		value &= ~(1 << ch->index);
 
 	sh_tmu_write(ch, TSTR, value);
-	raw_spin_unlock_irqrestore(&sh_tmu_lock, flags);
+	raw_spin_unlock_irqrestore(&ch->tmu->lock, flags);
 }
 
 static int __sh_tmu_enable(struct sh_tmu_channel *ch)
@@ -524,6 +524,8 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 	tmu->pdev = pdev;
 	tmu->model = id->driver_data;
 
+	raw_spin_lock_init(&tmu->lock);
+
 	/* Get hold of clock. */
 	tmu->clk = clk_get(&tmu->pdev->dev, "fck");
 	if (IS_ERR(tmu->clk)) {
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 05/19] clocksource: sh_tmu: Replace global spinlock with a per-device spinlock
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

The global spinlock is used to protect the shared start/stop register.
Now that all TMU channels are handled by a single device instance, use a
per-device spinlock.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/clocksource/sh_tmu.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 4363eb7..ef8fb0b 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -61,6 +61,8 @@ struct sh_tmu_device {
 
 	enum sh_tmu_model model;
 
+	raw_spinlock_t lock; /* Protect the shared start/stop register */
+
 	struct sh_tmu_channel *channels;
 	unsigned int num_channels;
 
@@ -68,8 +70,6 @@ struct sh_tmu_device {
 	bool has_clocksource;
 };
 
-static DEFINE_RAW_SPINLOCK(sh_tmu_lock);
-
 #define TSTR -1 /* shared register */
 #define TCOR  0 /* channel register */
 #define TCNT 1 /* channel register */
@@ -132,7 +132,7 @@ static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start)
 	unsigned long flags, value;
 
 	/* start stop register shared by multiple timer channels */
-	raw_spin_lock_irqsave(&sh_tmu_lock, flags);
+	raw_spin_lock_irqsave(&ch->tmu->lock, flags);
 	value = sh_tmu_read(ch, TSTR);
 
 	if (start)
@@ -141,7 +141,7 @@ static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start)
 		value &= ~(1 << ch->index);
 
 	sh_tmu_write(ch, TSTR, value);
-	raw_spin_unlock_irqrestore(&sh_tmu_lock, flags);
+	raw_spin_unlock_irqrestore(&ch->tmu->lock, flags);
 }
 
 static int __sh_tmu_enable(struct sh_tmu_channel *ch)
@@ -524,6 +524,8 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 	tmu->pdev = pdev;
 	tmu->model = id->driver_data;
 
+	raw_spin_lock_init(&tmu->lock);
+
 	/* Get hold of clock. */
 	tmu->clk = clk_get(&tmu->pdev->dev, "fck");
 	if (IS_ERR(tmu->clk)) {
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 06/19] clocksource: sh_mtu2: Drop support for legacy platform data
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Now that all platforms have switched to the new-style platform data,
drop support for the legacy version.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Wolfram Sang <wsa@sang-engineering.com>
---
 drivers/clocksource/sh_mtu2.c | 130 ++++++++++--------------------------------
 1 file changed, 31 insertions(+), 99 deletions(-)

diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index f2c1c36..2931fea 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -37,7 +37,6 @@ struct sh_mtu2_channel {
 	unsigned int index;
 
 	void __iomem *base;
-	int irq;
 
 	struct clock_event_device ced;
 };
@@ -51,7 +50,6 @@ struct sh_mtu2_device {
 	struct sh_mtu2_channel *channels;
 	unsigned int num_channels;
 
-	bool legacy;
 	bool has_clockevent;
 };
 
@@ -162,12 +160,8 @@ static inline unsigned long sh_mtu2_read(struct sh_mtu2_channel *ch, int reg_nr)
 {
 	unsigned long offs;
 
-	if (reg_nr = TSTR) {
-		if (ch->mtu->legacy)
-			return ioread8(ch->mtu->mapbase);
-		else
-			return ioread8(ch->mtu->mapbase + 0x280);
-	}
+	if (reg_nr = TSTR)
+		return ioread8(ch->mtu->mapbase + 0x280);
 
 	offs = mtu2_reg_offs[reg_nr];
 
@@ -182,12 +176,8 @@ static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr,
 {
 	unsigned long offs;
 
-	if (reg_nr = TSTR) {
-		if (ch->mtu->legacy)
-			return iowrite8(value, ch->mtu->mapbase);
-		else
-			return iowrite8(value, ch->mtu->mapbase + 0x280);
-	}
+	if (reg_nr = TSTR)
+		return iowrite8(value, ch->mtu->mapbase + 0x280);
 
 	offs = mtu2_reg_offs[reg_nr];
 
@@ -331,7 +321,6 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch,
 					const char *name)
 {
 	struct clock_event_device *ced = &ch->ced;
-	int ret;
 
 	ced->name = name;
 	ced->features = CLOCK_EVT_FEAT_PERIODIC;
@@ -344,24 +333,12 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch,
 	dev_info(&ch->mtu->pdev->dev, "ch%u: used for clock events\n",
 		 ch->index);
 	clockevents_register_device(ced);
-
-	ret = request_irq(ch->irq, sh_mtu2_interrupt,
-			  IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-			  dev_name(&ch->mtu->pdev->dev), ch);
-	if (ret) {
-		dev_err(&ch->mtu->pdev->dev, "ch%u: failed to request irq %d\n",
-			ch->index, ch->irq);
-		return;
-	}
 }
 
-static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name,
-			    bool clockevent)
+static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name)
 {
-	if (clockevent) {
-		ch->mtu->has_clockevent = true;
-		sh_mtu2_register_clockevent(ch, name);
-	}
+	ch->mtu->has_clockevent = true;
+	sh_mtu2_register_clockevent(ch, name);
 
 	return 0;
 }
@@ -372,40 +349,32 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
 	static const unsigned int channel_offsets[] = {
 		0x300, 0x380, 0x000,
 	};
-	bool clockevent;
+	char name[6];
+	int irq;
+	int ret;
 
 	ch->mtu = mtu;
 
-	if (mtu->legacy) {
-		struct sh_timer_config *cfg = mtu->pdev->dev.platform_data;
-
-		clockevent = cfg->clockevent_rating != 0;
-
-		ch->irq = platform_get_irq(mtu->pdev, 0);
-		ch->base = mtu->mapbase - cfg->channel_offset;
-		ch->index = cfg->timer_bit;
-	} else {
-		char name[6];
-
-		clockevent = true;
-
-		sprintf(name, "tgi%ua", index);
-		ch->irq = platform_get_irq_byname(mtu->pdev, name);
-		ch->base = mtu->mapbase + channel_offsets[index];
-		ch->index = index;
-	}
-
-	if (ch->irq < 0) {
+	sprintf(name, "tgi%ua", index);
+	irq = platform_get_irq_byname(mtu->pdev, name);
+	if (irq < 0) {
 		/* Skip channels with no declared interrupt. */
-		if (!mtu->legacy)
-			return 0;
+		return 0;
+	}
 
-		dev_err(&mtu->pdev->dev, "ch%u: failed to get irq\n",
-			ch->index);
-		return ch->irq;
+	ret = request_irq(irq, sh_mtu2_interrupt,
+			  IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+			  dev_name(&ch->mtu->pdev->dev), ch);
+	if (ret) {
+		dev_err(&ch->mtu->pdev->dev, "ch%u: failed to request irq %d\n",
+			index, irq);
+		return ret;
 	}
 
-	return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev), clockevent);
+	ch->base = mtu->mapbase + channel_offsets[index];
+	ch->index = index;
+
+	return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev));
 }
 
 static int sh_mtu2_map_memory(struct sh_mtu2_device *mtu)
@@ -422,46 +391,19 @@ static int sh_mtu2_map_memory(struct sh_mtu2_device *mtu)
 	if (mtu->mapbase = NULL)
 		return -ENXIO;
 
-	/*
-	 * In legacy platform device configuration (with one device per channel)
-	 * the resource points to the channel base address.
-	 */
-	if (mtu->legacy) {
-		struct sh_timer_config *cfg = mtu->pdev->dev.platform_data;
-		mtu->mapbase += cfg->channel_offset;
-	}
-
 	return 0;
 }
 
-static void sh_mtu2_unmap_memory(struct sh_mtu2_device *mtu)
-{
-	if (mtu->legacy) {
-		struct sh_timer_config *cfg = mtu->pdev->dev.platform_data;
-		mtu->mapbase -= cfg->channel_offset;
-	}
-
-	iounmap(mtu->mapbase);
-}
-
 static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 			 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;
 
 	mtu->pdev = pdev;
-	mtu->legacy = id->driver_data;
-
-	if (mtu->legacy && !cfg) {
-		dev_err(&mtu->pdev->dev, "missing platform data\n");
-		return -ENXIO;
-	}
 
 	/* Get hold of clock. */
-	mtu->clk = clk_get(&mtu->pdev->dev, mtu->legacy ? "mtu2_fck" : "fck");
+	mtu->clk = clk_get(&mtu->pdev->dev, "fck");
 	if (IS_ERR(mtu->clk)) {
 		dev_err(&mtu->pdev->dev, "cannot get clock\n");
 		return PTR_ERR(mtu->clk);
@@ -479,10 +421,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 	}
 
 	/* Allocate and setup the channels. */
-	if (mtu->legacy)
-		mtu->num_channels = 1;
-	else
-		mtu->num_channels = 3;
+	mtu->num_channels = 3;
 
 	mtu->channels = kzalloc(sizeof(*mtu->channels) * mtu->num_channels,
 				GFP_KERNEL);
@@ -491,16 +430,10 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 		goto err_unmap;
 	}
 
-	if (mtu->legacy) {
-		ret = sh_mtu2_setup_channel(&mtu->channels[0], 0, mtu);
+	for (i = 0; i < mtu->num_channels; ++i) {
+		ret = sh_mtu2_setup_channel(&mtu->channels[i], i, mtu);
 		if (ret < 0)
 			goto err_unmap;
-	} else {
-		for (i = 0; i < mtu->num_channels; ++i) {
-			ret = sh_mtu2_setup_channel(&mtu->channels[i], i, mtu);
-			if (ret < 0)
-				goto err_unmap;
-		}
 	}
 
 	platform_set_drvdata(pdev, mtu);
@@ -509,7 +442,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 
 err_unmap:
 	kfree(mtu->channels);
-	sh_mtu2_unmap_memory(mtu);
+	iounmap(mtu->mapbase);
 err_clk_unprepare:
 	clk_unprepare(mtu->clk);
 err_clk_put:
@@ -562,7 +495,6 @@ static int sh_mtu2_remove(struct platform_device *pdev)
 }
 
 static const struct platform_device_id sh_mtu2_id_table[] = {
-	{ "sh_mtu2", 1 },
 	{ "sh-mtu2", 0 },
 	{ },
 };
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 06/19] clocksource: sh_mtu2: Drop support for legacy platform data
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Now that all platforms have switched to the new-style platform data,
drop support for the legacy version.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Wolfram Sang <wsa@sang-engineering.com>
---
 drivers/clocksource/sh_mtu2.c | 130 ++++++++++--------------------------------
 1 file changed, 31 insertions(+), 99 deletions(-)

diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index f2c1c36..2931fea 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -37,7 +37,6 @@ struct sh_mtu2_channel {
 	unsigned int index;
 
 	void __iomem *base;
-	int irq;
 
 	struct clock_event_device ced;
 };
@@ -51,7 +50,6 @@ struct sh_mtu2_device {
 	struct sh_mtu2_channel *channels;
 	unsigned int num_channels;
 
-	bool legacy;
 	bool has_clockevent;
 };
 
@@ -162,12 +160,8 @@ static inline unsigned long sh_mtu2_read(struct sh_mtu2_channel *ch, int reg_nr)
 {
 	unsigned long offs;
 
-	if (reg_nr == TSTR) {
-		if (ch->mtu->legacy)
-			return ioread8(ch->mtu->mapbase);
-		else
-			return ioread8(ch->mtu->mapbase + 0x280);
-	}
+	if (reg_nr == TSTR)
+		return ioread8(ch->mtu->mapbase + 0x280);
 
 	offs = mtu2_reg_offs[reg_nr];
 
@@ -182,12 +176,8 @@ static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr,
 {
 	unsigned long offs;
 
-	if (reg_nr == TSTR) {
-		if (ch->mtu->legacy)
-			return iowrite8(value, ch->mtu->mapbase);
-		else
-			return iowrite8(value, ch->mtu->mapbase + 0x280);
-	}
+	if (reg_nr == TSTR)
+		return iowrite8(value, ch->mtu->mapbase + 0x280);
 
 	offs = mtu2_reg_offs[reg_nr];
 
@@ -331,7 +321,6 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch,
 					const char *name)
 {
 	struct clock_event_device *ced = &ch->ced;
-	int ret;
 
 	ced->name = name;
 	ced->features = CLOCK_EVT_FEAT_PERIODIC;
@@ -344,24 +333,12 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch,
 	dev_info(&ch->mtu->pdev->dev, "ch%u: used for clock events\n",
 		 ch->index);
 	clockevents_register_device(ced);
-
-	ret = request_irq(ch->irq, sh_mtu2_interrupt,
-			  IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-			  dev_name(&ch->mtu->pdev->dev), ch);
-	if (ret) {
-		dev_err(&ch->mtu->pdev->dev, "ch%u: failed to request irq %d\n",
-			ch->index, ch->irq);
-		return;
-	}
 }
 
-static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name,
-			    bool clockevent)
+static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name)
 {
-	if (clockevent) {
-		ch->mtu->has_clockevent = true;
-		sh_mtu2_register_clockevent(ch, name);
-	}
+	ch->mtu->has_clockevent = true;
+	sh_mtu2_register_clockevent(ch, name);
 
 	return 0;
 }
@@ -372,40 +349,32 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
 	static const unsigned int channel_offsets[] = {
 		0x300, 0x380, 0x000,
 	};
-	bool clockevent;
+	char name[6];
+	int irq;
+	int ret;
 
 	ch->mtu = mtu;
 
-	if (mtu->legacy) {
-		struct sh_timer_config *cfg = mtu->pdev->dev.platform_data;
-
-		clockevent = cfg->clockevent_rating != 0;
-
-		ch->irq = platform_get_irq(mtu->pdev, 0);
-		ch->base = mtu->mapbase - cfg->channel_offset;
-		ch->index = cfg->timer_bit;
-	} else {
-		char name[6];
-
-		clockevent = true;
-
-		sprintf(name, "tgi%ua", index);
-		ch->irq = platform_get_irq_byname(mtu->pdev, name);
-		ch->base = mtu->mapbase + channel_offsets[index];
-		ch->index = index;
-	}
-
-	if (ch->irq < 0) {
+	sprintf(name, "tgi%ua", index);
+	irq = platform_get_irq_byname(mtu->pdev, name);
+	if (irq < 0) {
 		/* Skip channels with no declared interrupt. */
-		if (!mtu->legacy)
-			return 0;
+		return 0;
+	}
 
-		dev_err(&mtu->pdev->dev, "ch%u: failed to get irq\n",
-			ch->index);
-		return ch->irq;
+	ret = request_irq(irq, sh_mtu2_interrupt,
+			  IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+			  dev_name(&ch->mtu->pdev->dev), ch);
+	if (ret) {
+		dev_err(&ch->mtu->pdev->dev, "ch%u: failed to request irq %d\n",
+			index, irq);
+		return ret;
 	}
 
-	return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev), clockevent);
+	ch->base = mtu->mapbase + channel_offsets[index];
+	ch->index = index;
+
+	return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev));
 }
 
 static int sh_mtu2_map_memory(struct sh_mtu2_device *mtu)
@@ -422,46 +391,19 @@ static int sh_mtu2_map_memory(struct sh_mtu2_device *mtu)
 	if (mtu->mapbase == NULL)
 		return -ENXIO;
 
-	/*
-	 * In legacy platform device configuration (with one device per channel)
-	 * the resource points to the channel base address.
-	 */
-	if (mtu->legacy) {
-		struct sh_timer_config *cfg = mtu->pdev->dev.platform_data;
-		mtu->mapbase += cfg->channel_offset;
-	}
-
 	return 0;
 }
 
-static void sh_mtu2_unmap_memory(struct sh_mtu2_device *mtu)
-{
-	if (mtu->legacy) {
-		struct sh_timer_config *cfg = mtu->pdev->dev.platform_data;
-		mtu->mapbase -= cfg->channel_offset;
-	}
-
-	iounmap(mtu->mapbase);
-}
-
 static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 			 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;
 
 	mtu->pdev = pdev;
-	mtu->legacy = id->driver_data;
-
-	if (mtu->legacy && !cfg) {
-		dev_err(&mtu->pdev->dev, "missing platform data\n");
-		return -ENXIO;
-	}
 
 	/* Get hold of clock. */
-	mtu->clk = clk_get(&mtu->pdev->dev, mtu->legacy ? "mtu2_fck" : "fck");
+	mtu->clk = clk_get(&mtu->pdev->dev, "fck");
 	if (IS_ERR(mtu->clk)) {
 		dev_err(&mtu->pdev->dev, "cannot get clock\n");
 		return PTR_ERR(mtu->clk);
@@ -479,10 +421,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 	}
 
 	/* Allocate and setup the channels. */
-	if (mtu->legacy)
-		mtu->num_channels = 1;
-	else
-		mtu->num_channels = 3;
+	mtu->num_channels = 3;
 
 	mtu->channels = kzalloc(sizeof(*mtu->channels) * mtu->num_channels,
 				GFP_KERNEL);
@@ -491,16 +430,10 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 		goto err_unmap;
 	}
 
-	if (mtu->legacy) {
-		ret = sh_mtu2_setup_channel(&mtu->channels[0], 0, mtu);
+	for (i = 0; i < mtu->num_channels; ++i) {
+		ret = sh_mtu2_setup_channel(&mtu->channels[i], i, mtu);
 		if (ret < 0)
 			goto err_unmap;
-	} else {
-		for (i = 0; i < mtu->num_channels; ++i) {
-			ret = sh_mtu2_setup_channel(&mtu->channels[i], i, mtu);
-			if (ret < 0)
-				goto err_unmap;
-		}
 	}
 
 	platform_set_drvdata(pdev, mtu);
@@ -509,7 +442,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 
 err_unmap:
 	kfree(mtu->channels);
-	sh_mtu2_unmap_memory(mtu);
+	iounmap(mtu->mapbase);
 err_clk_unprepare:
 	clk_unprepare(mtu->clk);
 err_clk_put:
@@ -562,7 +495,6 @@ static int sh_mtu2_remove(struct platform_device *pdev)
 }
 
 static const struct platform_device_id sh_mtu2_id_table[] = {
-	{ "sh_mtu2", 1 },
 	{ "sh-mtu2", 0 },
 	{ },
 };
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 07/19] clocksource: sh_mtu2: Replace global spinlock with a per-device spinlock
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

The global spinlock is used to protect the shared start/stop register.
Now that all MTU2 channels are handled by a single device instance, use
a per-device spinlock.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Wolfram Sang <wsa@sang-engineering.com>
---
 drivers/clocksource/sh_mtu2.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index 2931fea..ebdf9d1 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -47,14 +47,14 @@ struct sh_mtu2_device {
 	void __iomem *mapbase;
 	struct clk *clk;
 
+	raw_spinlock_t lock; /* Protect the shared registers */
+
 	struct sh_mtu2_channel *channels;
 	unsigned int num_channels;
 
 	bool has_clockevent;
 };
 
-static DEFINE_RAW_SPINLOCK(sh_mtu2_lock);
-
 #define TSTR -1 /* shared register */
 #define TCR  0 /* channel register */
 #define TMDR 1 /* channel register */
@@ -192,7 +192,7 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start)
 	unsigned long flags, value;
 
 	/* start stop register shared by multiple timer channels */
-	raw_spin_lock_irqsave(&sh_mtu2_lock, flags);
+	raw_spin_lock_irqsave(&ch->mtu->lock, flags);
 	value = sh_mtu2_read(ch, TSTR);
 
 	if (start)
@@ -201,7 +201,7 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start)
 		value &= ~(1 << ch->index);
 
 	sh_mtu2_write(ch, TSTR, value);
-	raw_spin_unlock_irqrestore(&sh_mtu2_lock, flags);
+	raw_spin_unlock_irqrestore(&ch->mtu->lock, flags);
 }
 
 static int sh_mtu2_enable(struct sh_mtu2_channel *ch)
@@ -402,6 +402,8 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 
 	mtu->pdev = pdev;
 
+	raw_spin_lock_init(&mtu->lock);
+
 	/* Get hold of clock. */
 	mtu->clk = clk_get(&mtu->pdev->dev, "fck");
 	if (IS_ERR(mtu->clk)) {
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 07/19] clocksource: sh_mtu2: Replace global spinlock with a per-device spinlock
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

The global spinlock is used to protect the shared start/stop register.
Now that all MTU2 channels are handled by a single device instance, use
a per-device spinlock.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Wolfram Sang <wsa@sang-engineering.com>
---
 drivers/clocksource/sh_mtu2.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index 2931fea..ebdf9d1 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -47,14 +47,14 @@ struct sh_mtu2_device {
 	void __iomem *mapbase;
 	struct clk *clk;
 
+	raw_spinlock_t lock; /* Protect the shared registers */
+
 	struct sh_mtu2_channel *channels;
 	unsigned int num_channels;
 
 	bool has_clockevent;
 };
 
-static DEFINE_RAW_SPINLOCK(sh_mtu2_lock);
-
 #define TSTR -1 /* shared register */
 #define TCR  0 /* channel register */
 #define TMDR 1 /* channel register */
@@ -192,7 +192,7 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start)
 	unsigned long flags, value;
 
 	/* start stop register shared by multiple timer channels */
-	raw_spin_lock_irqsave(&sh_mtu2_lock, flags);
+	raw_spin_lock_irqsave(&ch->mtu->lock, flags);
 	value = sh_mtu2_read(ch, TSTR);
 
 	if (start)
@@ -201,7 +201,7 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start)
 		value &= ~(1 << ch->index);
 
 	sh_mtu2_write(ch, TSTR, value);
-	raw_spin_unlock_irqrestore(&sh_mtu2_lock, flags);
+	raw_spin_unlock_irqrestore(&ch->mtu->lock, flags);
 }
 
 static int sh_mtu2_enable(struct sh_mtu2_channel *ch)
@@ -402,6 +402,8 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
 
 	mtu->pdev = pdev;
 
+	raw_spin_lock_init(&mtu->lock);
+
 	/* Get hold of clock. */
 	mtu->clk = clk_get(&mtu->pdev->dev, "fck");
 	if (IS_ERR(mtu->clk)) {
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 08/19] clocksource: shmobile: Remove unused sh_timer_config members
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

The name, channel_offset, timer_bit, clockevent_rating and
clocksource_rating members are unused. Remove them.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 include/linux/sh_timer.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/include/linux/sh_timer.h b/include/linux/sh_timer.h
index 8e1e036..64638b0 100644
--- a/include/linux/sh_timer.h
+++ b/include/linux/sh_timer.h
@@ -2,11 +2,6 @@
 #define __SH_TIMER_H__
 
 struct sh_timer_config {
-	char *name;
-	long channel_offset;
-	int timer_bit;
-	unsigned long clockevent_rating;
-	unsigned long clocksource_rating;
 	unsigned int channels_mask;
 };
 
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 08/19] clocksource: shmobile: Remove unused sh_timer_config members
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

The name, channel_offset, timer_bit, clockevent_rating and
clocksource_rating members are unused. Remove them.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 include/linux/sh_timer.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/include/linux/sh_timer.h b/include/linux/sh_timer.h
index 8e1e036..64638b0 100644
--- a/include/linux/sh_timer.h
+++ b/include/linux/sh_timer.h
@@ -2,11 +2,6 @@
 #define __SH_TIMER_H__
 
 struct sh_timer_config {
-	char *name;
-	long channel_offset;
-	int timer_bit;
-	unsigned long clockevent_rating;
-	unsigned long clocksource_rating;
 	unsigned int channels_mask;
 };
 
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 09/19] clocksource: sh_cmt: Add DT support
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Document DT bindings and parse them in the CMT driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 .../devicetree/bindings/timer/renesas,cmt.txt      | 49 ++++++++++++++++
 drivers/clocksource/sh_cmt.c                       | 66 ++++++++++++++++------
 2 files changed, 97 insertions(+), 18 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,cmt.txt

diff --git a/Documentation/devicetree/bindings/timer/renesas,cmt.txt b/Documentation/devicetree/bindings/timer/renesas,cmt.txt
new file mode 100644
index 0000000..d6a82cd
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/renesas,cmt.txt
@@ -0,0 +1,49 @@
+* Renesas R-Car Compare Match Timer (CMT)
+
+The CMT is a multi-channel 16/32/48-bit timer/counter with configurable clock
+inputs and programmable compare match.
+
+Channels share hardware resources but their counter and compare match value
+are independent. A particular CMT instance can implement only a subset of the
+channels supported by the CMT model. Channel indices represent the hardware
+position of the channel in the CMT and don't match the channel numbers in the
+datasheets.
+
+Required Properties:
+
+  - compatible: must contain one of the following.
+    - "renesas,cmt-32" for the 32-bit CMT
+		(CMT0 on sh7372, sh73a0 and r8a7740)
+    - "renesas,cmt-32-fast" for the 32-bit CMT with fast clock support
+		(CMT[234] on sh7372, sh73a0 and r8a7740)
+    - "renasas,cmt-48" for the 48-bit CMT
+		(CMT1 on sh7372, sh73a0 and r8a7740)
+    - "renesas,cmt-48-gen2" for the second generation 48-bit CMT
+		(CMT[01] on r8a73a4, r8a7790 and r8a7791)
+
+  - reg: base address and length of the registers block for the timer module.
+  - interrupt-parent, 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.
+
+  - renesas,channels-mask: bitmask of the available channels.
+
+
+Example: R8A7790 (R-Car H2) CMT0 node
+
+	CMT0 on R8A7790 implements hardware channels 5 and 6 only and names
+	them channels 0 and 1 in the documentation.
+
+	cmt0: timer@ffca0000 {
+		compatible = "renesas,cmt-48-gen2";
+		reg = <0 0xffca0000 0 0x1004>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 142 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
+		clock-names = "fck";
+
+		renesas,channels-mask = <0x60>;
+	};
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 4d00e4b..3a27ce3 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.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>
@@ -122,6 +123,7 @@ struct sh_cmt_device {
 
 	struct sh_cmt_channel *channels;
 	unsigned int num_channels;
+	unsigned int hw_channels;
 
 	bool has_clockevent;
 	bool has_clocksource;
@@ -924,10 +926,35 @@ static int sh_cmt_map_memory(struct sh_cmt_device *cmt)
 	return 0;
 }
 
+static const struct platform_device_id sh_cmt_id_table[] = {
+	{ "sh-cmt-16", (kernel_ulong_t)&sh_cmt_info[SH_CMT_16BIT] },
+	{ "sh-cmt-32", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT] },
+	{ "sh-cmt-32-fast", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT_FAST] },
+	{ "sh-cmt-48", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT] },
+	{ "sh-cmt-48-gen2", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT_GEN2] },
+	{ }
+};
+MODULE_DEVICE_TABLE(platform, sh_cmt_id_table);
+
+static const struct of_device_id sh_cmt_of_table[] = {
+	{ .compatible = "renesas,cmt-32", .data = &sh_cmt_info[SH_CMT_32BIT] },
+	{ .compatible = "renesas,cmt-32-fast", .data = &sh_cmt_info[SH_CMT_32BIT_FAST] },
+	{ .compatible = "renasas,cmt-48", .data = &sh_cmt_info[SH_CMT_48BIT] },
+	{ .compatible = "renesas,cmt-48-gen2", .data = &sh_cmt_info[SH_CMT_48BIT_GEN2] },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sh_cmt_of_table);
+
+static int sh_cmt_parse_dt(struct sh_cmt_device *cmt)
+{
+	struct device_node *np = cmt->pdev->dev.of_node;
+
+	return of_property_read_u32(np, "renesas,channels-mask",
+				    &cmt->hw_channels);
+}
+
 static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 {
-	struct sh_timer_config *cfg = pdev->dev.platform_data;
-	const struct platform_device_id *id = pdev->id_entry;
 	unsigned int mask;
 	unsigned int i;
 	int ret;
@@ -936,13 +963,26 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 	cmt->pdev = pdev;
 	raw_spin_lock_init(&cmt->lock);
 
-	if (!cfg) {
+	if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
+		const struct of_device_id *id;
+
+		id = of_match_node(sh_cmt_of_table, pdev->dev.of_node);
+		cmt->info = id->data;
+
+		ret = sh_cmt_parse_dt(cmt);
+		if (ret < 0)
+			return ret;
+	} else if (pdev->dev.platform_data) {
+		struct sh_timer_config *cfg = pdev->dev.platform_data;
+		const struct platform_device_id *id = pdev->id_entry;
+
+		cmt->info = (const struct sh_cmt_info *)id->driver_data;
+		cmt->hw_channels = cfg->channels_mask;
+	} else {
 		dev_err(&cmt->pdev->dev, "missing platform data\n");
 		return -ENXIO;
 	}
 
-	cmt->info = (const struct sh_cmt_info *)id->driver_data;
-
 	/* Get hold of clock. */
 	cmt->clk = clk_get(&cmt->pdev->dev, "fck");
 	if (IS_ERR(cmt->clk)) {
@@ -960,8 +1000,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 		goto err_clk_unprepare;
 
 	/* Allocate and setup the channels. */
-	cmt->num_channels = hweight8(cfg->channels_mask);
-
+	cmt->num_channels = hweight8(cmt->hw_channels);
 	cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels),
 				GFP_KERNEL);
 	if (cmt->channels = NULL) {
@@ -973,7 +1012,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 	 * Use the first channel as a clock event device and the second channel
 	 * as a clock source. If only one channel is available use it for both.
 	 */
-	for (i = 0, mask = cfg->channels_mask; i < cmt->num_channels; ++i) {
+	for (i = 0, mask = cmt->hw_channels; i < cmt->num_channels; ++i) {
 		unsigned int hwidx = ffs(mask) - 1;
 		bool clocksource = i = 1 || cmt->num_channels = 1;
 		bool clockevent = i = 0;
@@ -1044,21 +1083,12 @@ static int sh_cmt_remove(struct platform_device *pdev)
 	return -EBUSY; /* cannot unregister clockevent and clocksource */
 }
 
-static const struct platform_device_id sh_cmt_id_table[] = {
-	{ "sh-cmt-16", (kernel_ulong_t)&sh_cmt_info[SH_CMT_16BIT] },
-	{ "sh-cmt-32", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT] },
-	{ "sh-cmt-32-fast", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT_FAST] },
-	{ "sh-cmt-48", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT] },
-	{ "sh-cmt-48-gen2", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT_GEN2] },
-	{ }
-};
-MODULE_DEVICE_TABLE(platform, sh_cmt_id_table);
-
 static struct platform_driver sh_cmt_device_driver = {
 	.probe		= sh_cmt_probe,
 	.remove		= sh_cmt_remove,
 	.driver		= {
 		.name	= "sh_cmt",
+		.of_match_table = of_match_ptr(sh_cmt_of_table),
 	},
 	.id_table	= sh_cmt_id_table,
 };
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 09/19] clocksource: sh_cmt: Add DT support
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Document DT bindings and parse them in the CMT driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 .../devicetree/bindings/timer/renesas,cmt.txt      | 49 ++++++++++++++++
 drivers/clocksource/sh_cmt.c                       | 66 ++++++++++++++++------
 2 files changed, 97 insertions(+), 18 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,cmt.txt

diff --git a/Documentation/devicetree/bindings/timer/renesas,cmt.txt b/Documentation/devicetree/bindings/timer/renesas,cmt.txt
new file mode 100644
index 0000000..d6a82cd
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/renesas,cmt.txt
@@ -0,0 +1,49 @@
+* Renesas R-Car Compare Match Timer (CMT)
+
+The CMT is a multi-channel 16/32/48-bit timer/counter with configurable clock
+inputs and programmable compare match.
+
+Channels share hardware resources but their counter and compare match value
+are independent. A particular CMT instance can implement only a subset of the
+channels supported by the CMT model. Channel indices represent the hardware
+position of the channel in the CMT and don't match the channel numbers in the
+datasheets.
+
+Required Properties:
+
+  - compatible: must contain one of the following.
+    - "renesas,cmt-32" for the 32-bit CMT
+		(CMT0 on sh7372, sh73a0 and r8a7740)
+    - "renesas,cmt-32-fast" for the 32-bit CMT with fast clock support
+		(CMT[234] on sh7372, sh73a0 and r8a7740)
+    - "renasas,cmt-48" for the 48-bit CMT
+		(CMT1 on sh7372, sh73a0 and r8a7740)
+    - "renesas,cmt-48-gen2" for the second generation 48-bit CMT
+		(CMT[01] on r8a73a4, r8a7790 and r8a7791)
+
+  - reg: base address and length of the registers block for the timer module.
+  - interrupt-parent, 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.
+
+  - renesas,channels-mask: bitmask of the available channels.
+
+
+Example: R8A7790 (R-Car H2) CMT0 node
+
+	CMT0 on R8A7790 implements hardware channels 5 and 6 only and names
+	them channels 0 and 1 in the documentation.
+
+	cmt0: timer at ffca0000 {
+		compatible = "renesas,cmt-48-gen2";
+		reg = <0 0xffca0000 0 0x1004>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 142 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
+		clock-names = "fck";
+
+		renesas,channels-mask = <0x60>;
+	};
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 4d00e4b..3a27ce3 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.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>
@@ -122,6 +123,7 @@ struct sh_cmt_device {
 
 	struct sh_cmt_channel *channels;
 	unsigned int num_channels;
+	unsigned int hw_channels;
 
 	bool has_clockevent;
 	bool has_clocksource;
@@ -924,10 +926,35 @@ static int sh_cmt_map_memory(struct sh_cmt_device *cmt)
 	return 0;
 }
 
+static const struct platform_device_id sh_cmt_id_table[] = {
+	{ "sh-cmt-16", (kernel_ulong_t)&sh_cmt_info[SH_CMT_16BIT] },
+	{ "sh-cmt-32", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT] },
+	{ "sh-cmt-32-fast", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT_FAST] },
+	{ "sh-cmt-48", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT] },
+	{ "sh-cmt-48-gen2", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT_GEN2] },
+	{ }
+};
+MODULE_DEVICE_TABLE(platform, sh_cmt_id_table);
+
+static const struct of_device_id sh_cmt_of_table[] = {
+	{ .compatible = "renesas,cmt-32", .data = &sh_cmt_info[SH_CMT_32BIT] },
+	{ .compatible = "renesas,cmt-32-fast", .data = &sh_cmt_info[SH_CMT_32BIT_FAST] },
+	{ .compatible = "renasas,cmt-48", .data = &sh_cmt_info[SH_CMT_48BIT] },
+	{ .compatible = "renesas,cmt-48-gen2", .data = &sh_cmt_info[SH_CMT_48BIT_GEN2] },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sh_cmt_of_table);
+
+static int sh_cmt_parse_dt(struct sh_cmt_device *cmt)
+{
+	struct device_node *np = cmt->pdev->dev.of_node;
+
+	return of_property_read_u32(np, "renesas,channels-mask",
+				    &cmt->hw_channels);
+}
+
 static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 {
-	struct sh_timer_config *cfg = pdev->dev.platform_data;
-	const struct platform_device_id *id = pdev->id_entry;
 	unsigned int mask;
 	unsigned int i;
 	int ret;
@@ -936,13 +963,26 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 	cmt->pdev = pdev;
 	raw_spin_lock_init(&cmt->lock);
 
-	if (!cfg) {
+	if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
+		const struct of_device_id *id;
+
+		id = of_match_node(sh_cmt_of_table, pdev->dev.of_node);
+		cmt->info = id->data;
+
+		ret = sh_cmt_parse_dt(cmt);
+		if (ret < 0)
+			return ret;
+	} else if (pdev->dev.platform_data) {
+		struct sh_timer_config *cfg = pdev->dev.platform_data;
+		const struct platform_device_id *id = pdev->id_entry;
+
+		cmt->info = (const struct sh_cmt_info *)id->driver_data;
+		cmt->hw_channels = cfg->channels_mask;
+	} else {
 		dev_err(&cmt->pdev->dev, "missing platform data\n");
 		return -ENXIO;
 	}
 
-	cmt->info = (const struct sh_cmt_info *)id->driver_data;
-
 	/* Get hold of clock. */
 	cmt->clk = clk_get(&cmt->pdev->dev, "fck");
 	if (IS_ERR(cmt->clk)) {
@@ -960,8 +1000,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 		goto err_clk_unprepare;
 
 	/* Allocate and setup the channels. */
-	cmt->num_channels = hweight8(cfg->channels_mask);
-
+	cmt->num_channels = hweight8(cmt->hw_channels);
 	cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels),
 				GFP_KERNEL);
 	if (cmt->channels == NULL) {
@@ -973,7 +1012,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 	 * Use the first channel as a clock event device and the second channel
 	 * as a clock source. If only one channel is available use it for both.
 	 */
-	for (i = 0, mask = cfg->channels_mask; i < cmt->num_channels; ++i) {
+	for (i = 0, mask = cmt->hw_channels; i < cmt->num_channels; ++i) {
 		unsigned int hwidx = ffs(mask) - 1;
 		bool clocksource = i == 1 || cmt->num_channels == 1;
 		bool clockevent = i == 0;
@@ -1044,21 +1083,12 @@ static int sh_cmt_remove(struct platform_device *pdev)
 	return -EBUSY; /* cannot unregister clockevent and clocksource */
 }
 
-static const struct platform_device_id sh_cmt_id_table[] = {
-	{ "sh-cmt-16", (kernel_ulong_t)&sh_cmt_info[SH_CMT_16BIT] },
-	{ "sh-cmt-32", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT] },
-	{ "sh-cmt-32-fast", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT_FAST] },
-	{ "sh-cmt-48", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT] },
-	{ "sh-cmt-48-gen2", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT_GEN2] },
-	{ }
-};
-MODULE_DEVICE_TABLE(platform, sh_cmt_id_table);
-
 static struct platform_driver sh_cmt_device_driver = {
 	.probe		= sh_cmt_probe,
 	.remove		= sh_cmt_remove,
 	.driver		= {
 		.name	= "sh_cmt",
+		.of_match_table = of_match_ptr(sh_cmt_of_table),
 	},
 	.id_table	= sh_cmt_id_table,
 };
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 10/19] clocksource: sh_tmu: Add DT support
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Document DT bindings and parse them in the TMU driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 .../devicetree/bindings/timer/renesas,tmu.txt      | 40 +++++++++++++++++++
 drivers/clocksource/sh_tmu.c                       | 45 ++++++++++++++++++----
 2 files changed, 77 insertions(+), 8 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..2392e89
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/renesas,tmu.txt
@@ -0,0 +1,40 @@
+* 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>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 42 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..2ece4ab 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,46 @@ 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->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) {
+		struct sh_timer_config *cfg = pdev->dev.platform_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 +569,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 +652,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[] = {
+	{ .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 = sh_tmu_of_table,
 	},
 	.id_table	= sh_tmu_id_table,
 };
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 10/19] clocksource: sh_tmu: Add DT support
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Document DT bindings and parse them in the TMU driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 .../devicetree/bindings/timer/renesas,tmu.txt      | 40 +++++++++++++++++++
 drivers/clocksource/sh_tmu.c                       | 45 ++++++++++++++++++----
 2 files changed, 77 insertions(+), 8 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..2392e89
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/renesas,tmu.txt
@@ -0,0 +1,40 @@
+* 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 at ffd80000 {
+		compatible = "renesas,tmu";
+		reg = <0xffd80000 0x30>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 42 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..2ece4ab 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,46 @@ 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->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) {
+		struct sh_timer_config *cfg = pdev->dev.platform_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 +569,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 +652,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[] = {
+	{ .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 = sh_tmu_of_table,
 	},
 	.id_table	= sh_tmu_id_table,
 };
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 11/19] clocksource: sh_mtu2: Add DT support
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Document DT bindings and parse them in the MTU2 driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Wolfram Sang <wsa@sang-engineering.com>
---
 .../devicetree/bindings/timer/renesas,mtu2.txt     | 40 ++++++++++++++++++++++
 drivers/clocksource/sh_mtu2.c                      |  8 +++++
 2 files changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,mtu2.txt

diff --git a/Documentation/devicetree/bindings/timer/renesas,mtu2.txt b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
new file mode 100644
index 0000000..c5dd032
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
@@ -0,0 +1,40 @@
+* Renesas R-Car Multi-Function Timer Pulse Unit 2 (MTU2)
+
+The MTU2 is a multi-purpose, multi-channel timer/counter with configurable
+clock inputs and programmable compare match.
+
+Channels share hardware resources but their counter and compare match value
+are independent. The MTU2 hardware supports five channels indexed from 0 to 4.
+
+Required Properties:
+
+  - compatible: must contain "renesas,mtu2"
+
+  - reg: base address and length of the registers block for the timer module.
+
+  - interrupt-parent, interrupts: interrupt specifiers for the timer, one for
+    each entry in interrupt-names.
+  - interrupt-names: must contain one entry named "tgi?a" for each enabled
+    channel, where "?" is the channel index expressed as one digit from "0" to
+    "4".
+
+  - clocks: a list of phandle + clock-specifier pairs, one for each entry
+    in clock-names.
+  - clock-names: must contain "fck" for the functional clock.
+
+
+Example: R7S72100 (RZ/A1H) MTU2 node
+
+	mtu2: timer@fcff0000 {
+		compatible = "renesas,mtu2";
+		reg = <0xfcff0000 0x400>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 139 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 146 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 150 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 154 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 159 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "tgi0a", "tgi1a", "tgi2a", "tgi3a", "tgi4a";
+		clocks = <&mstp3_clks R7S72100_CLK_MTU2>;
+		clock-names = "fck";
+	};
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index ebdf9d1..79387af 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -23,6 +23,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>
@@ -502,11 +503,18 @@ static const struct platform_device_id sh_mtu2_id_table[] = {
 };
 MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table);
 
+static const struct of_device_id sh_mtu2_of_table[] = {
+	{ .compatible = "renesas,mtu2" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sh_mtu2_of_table);
+
 static struct platform_driver sh_mtu2_device_driver = {
 	.probe		= sh_mtu2_probe,
 	.remove		= sh_mtu2_remove,
 	.driver		= {
 		.name	= "sh_mtu2",
+		.of_match_table = of_match_ptr(sh_mtu2_of_table),
 	},
 	.id_table	= sh_mtu2_id_table,
 };
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 11/19] clocksource: sh_mtu2: Add DT support
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Document DT bindings and parse them in the MTU2 driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tested-by: Wolfram Sang <wsa@sang-engineering.com>
---
 .../devicetree/bindings/timer/renesas,mtu2.txt     | 40 ++++++++++++++++++++++
 drivers/clocksource/sh_mtu2.c                      |  8 +++++
 2 files changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/renesas,mtu2.txt

diff --git a/Documentation/devicetree/bindings/timer/renesas,mtu2.txt b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
new file mode 100644
index 0000000..c5dd032
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
@@ -0,0 +1,40 @@
+* Renesas R-Car Multi-Function Timer Pulse Unit 2 (MTU2)
+
+The MTU2 is a multi-purpose, multi-channel timer/counter with configurable
+clock inputs and programmable compare match.
+
+Channels share hardware resources but their counter and compare match value
+are independent. The MTU2 hardware supports five channels indexed from 0 to 4.
+
+Required Properties:
+
+  - compatible: must contain "renesas,mtu2"
+
+  - reg: base address and length of the registers block for the timer module.
+
+  - interrupt-parent, interrupts: interrupt specifiers for the timer, one for
+    each entry in interrupt-names.
+  - interrupt-names: must contain one entry named "tgi?a" for each enabled
+    channel, where "?" is the channel index expressed as one digit from "0" to
+    "4".
+
+  - clocks: a list of phandle + clock-specifier pairs, one for each entry
+    in clock-names.
+  - clock-names: must contain "fck" for the functional clock.
+
+
+Example: R7S72100 (RZ/A1H) MTU2 node
+
+	mtu2: timer at fcff0000 {
+		compatible = "renesas,mtu2";
+		reg = <0xfcff0000 0x400>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 139 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 146 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 150 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 154 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 159 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "tgi0a", "tgi1a", "tgi2a", "tgi3a", "tgi4a";
+		clocks = <&mstp3_clks R7S72100_CLK_MTU2>;
+		clock-names = "fck";
+	};
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index ebdf9d1..79387af 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -23,6 +23,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>
@@ -502,11 +503,18 @@ static const struct platform_device_id sh_mtu2_id_table[] = {
 };
 MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table);
 
+static const struct of_device_id sh_mtu2_of_table[] = {
+	{ .compatible = "renesas,mtu2" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sh_mtu2_of_table);
+
 static struct platform_driver sh_mtu2_device_driver = {
 	.probe		= sh_mtu2_probe,
 	.remove		= sh_mtu2_remove,
 	.driver		= {
 		.name	= "sh_mtu2",
+		.of_match_table = of_match_ptr(sh_mtu2_of_table),
 	},
 	.id_table	= sh_mtu2_id_table,
 };
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 12/19] ARM: shmobile: r8a7790: Add CMT devices to DT
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add the CMT0 and CMT1 counters to the r8a7790 device tree and make them
disabled by default.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7790.dtsi | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 29907c9..cc32ac5 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -206,6 +206,40 @@
 			     <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
 	};
 
+	cmt0: timer@ffca0000 {
+		compatible = "renesas,cmt-48-gen2";
+		reg = <0 0xffca0000 0 0x1004>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
+		clock-names = "fck";
+
+		renesas,channels-mask = <0x60>;
+
+		status = "disabled";
+	};
+
+	cmt1: timer@e6130000 {
+		compatible = "renesas,cmt-48-gen2";
+		reg = <0 0xe6130000 0 0x1004>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 121 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 122 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 123 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 124 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 125 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 126 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 127 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp3_clks R8A7790_CLK_CMT1>;
+		clock-names = "fck";
+
+		renesas,channels-mask = <0xff>;
+
+		status = "disabled";
+	};
+
 	irqc0: interrupt-controller@e61c0000 {
 		compatible = "renesas,irqc-r8a7790", "renesas,irqc";
 		#interrupt-cells = <2>;
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 12/19] ARM: shmobile: r8a7790: Add CMT devices to DT
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add the CMT0 and CMT1 counters to the r8a7790 device tree and make them
disabled by default.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7790.dtsi | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 29907c9..cc32ac5 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -206,6 +206,40 @@
 			     <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
 	};
 
+	cmt0: timer at ffca0000 {
+		compatible = "renesas,cmt-48-gen2";
+		reg = <0 0xffca0000 0 0x1004>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
+		clock-names = "fck";
+
+		renesas,channels-mask = <0x60>;
+
+		status = "disabled";
+	};
+
+	cmt1: timer at e6130000 {
+		compatible = "renesas,cmt-48-gen2";
+		reg = <0 0xe6130000 0 0x1004>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 121 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 122 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 123 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 124 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 125 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 126 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 127 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp3_clks R8A7790_CLK_CMT1>;
+		clock-names = "fck";
+
+		renesas,channels-mask = <0xff>;
+
+		status = "disabled";
+	};
+
 	irqc0: interrupt-controller at e61c0000 {
 		compatible = "renesas,irqc-r8a7790", "renesas,irqc";
 		#interrupt-cells = <2>;
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 13/19] ARM: shmobile: r8a7791: Add CMT devices to DT
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add the CMT0 and CMT1 counters to the r8a7791 device tree and make them
disabled by default.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7791.dtsi | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
index 380d058..b56a995 100644
--- a/arch/arm/boot/dts/r8a7791.dtsi
+++ b/arch/arm/boot/dts/r8a7791.dtsi
@@ -189,6 +189,40 @@
 			     <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
 	};
 
+	cmt0: timer@ffca0000 {
+		compatible = "renesas,cmt-48-gen2";
+		reg = <0 0xffca0000 0 0x1004>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp1_clks R8A7791_CLK_CMT0>;
+		clock-names = "fck";
+
+		renesas,channels-mask = <0x60>;
+
+		status = "disabled";
+	};
+
+	cmt1: timer@e6130000 {
+		compatible = "renesas,cmt-48-gen2";
+		reg = <0 0xe6130000 0 0x1004>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 121 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 122 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 123 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 124 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 125 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 126 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 127 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp3_clks R8A7791_CLK_CMT1>;
+		clock-names = "fck";
+
+		renesas,channels-mask = <0xff>;
+
+		status = "disabled";
+	};
+
 	irqc0: interrupt-controller@e61c0000 {
 		compatible = "renesas,irqc-r8a7791", "renesas,irqc";
 		#interrupt-cells = <2>;
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 13/19] ARM: shmobile: r8a7791: Add CMT devices to DT
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add the CMT0 and CMT1 counters to the r8a7791 device tree and make them
disabled by default.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7791.dtsi | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
index 380d058..b56a995 100644
--- a/arch/arm/boot/dts/r8a7791.dtsi
+++ b/arch/arm/boot/dts/r8a7791.dtsi
@@ -189,6 +189,40 @@
 			     <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
 	};
 
+	cmt0: timer at ffca0000 {
+		compatible = "renesas,cmt-48-gen2";
+		reg = <0 0xffca0000 0 0x1004>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp1_clks R8A7791_CLK_CMT0>;
+		clock-names = "fck";
+
+		renesas,channels-mask = <0x60>;
+
+		status = "disabled";
+	};
+
+	cmt1: timer at e6130000 {
+		compatible = "renesas,cmt-48-gen2";
+		reg = <0 0xe6130000 0 0x1004>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 121 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 122 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 123 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 124 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 125 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 126 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 127 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp3_clks R8A7791_CLK_CMT1>;
+		clock-names = "fck";
+
+		renesas,channels-mask = <0xff>;
+
+		status = "disabled";
+	};
+
 	irqc0: interrupt-controller at e61c0000 {
 		compatible = "renesas,irqc-r8a7791", "renesas,irqc";
 		#interrupt-cells = <2>;
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add the TMU0, TMU1 and TMU2 counters to the r8a7779 device tree and make
them disabled by default.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7779.dtsi | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
index 94e2fc8..bf716ce 100644
--- a/arch/arm/boot/dts/r8a7779.dtsi
+++ b/arch/arm/boot/dts/r8a7779.dtsi
@@ -266,6 +266,48 @@
 		reg = <0xffc48000 0x38>;
 	};
 
+	tmu0: timer@ffd80000 {
+		compatible = "renesas,tmu";
+		reg = <0xffd80000 0x30>;
+		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
+		clock-names = "fck";
+
+		#renesas,channels = <3>;
+
+		status = "disabled";
+	};
+
+	tmu1: timer@ffd81000 {
+		compatible = "renesas,tmu";
+		reg = <0xffd81000 0x30>;
+		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
+		clock-names = "fck";
+
+		#renesas,channels = <3>;
+
+		status = "disabled";
+	};
+
+	tmu2: timer@ffd82000 {
+		compatible = "renesas,tmu";
+		reg = <0xffd82000 0x30>;
+		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
+		clock-names = "fck";
+
+		#renesas,channels = <3>;
+
+		status = "disabled";
+	};
+
 	sata: sata@fc600000 {
 		compatible = "renesas,rcar-sata";
 		reg = <0xfc600000 0x2000>;
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add the TMU0, TMU1 and TMU2 counters to the r8a7779 device tree and make
them disabled by default.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7779.dtsi | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
index 94e2fc8..bf716ce 100644
--- a/arch/arm/boot/dts/r8a7779.dtsi
+++ b/arch/arm/boot/dts/r8a7779.dtsi
@@ -266,6 +266,48 @@
 		reg = <0xffc48000 0x38>;
 	};
 
+	tmu0: timer at ffd80000 {
+		compatible = "renesas,tmu";
+		reg = <0xffd80000 0x30>;
+		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
+		clock-names = "fck";
+
+		#renesas,channels = <3>;
+
+		status = "disabled";
+	};
+
+	tmu1: timer at ffd81000 {
+		compatible = "renesas,tmu";
+		reg = <0xffd81000 0x30>;
+		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
+		clock-names = "fck";
+
+		#renesas,channels = <3>;
+
+		status = "disabled";
+	};
+
+	tmu2: timer at ffd82000 {
+		compatible = "renesas,tmu";
+		reg = <0xffd82000 0x30>;
+		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
+		clock-names = "fck";
+
+		#renesas,channels = <3>;
+
+		status = "disabled";
+	};
+
 	sata: sata at fc600000 {
 		compatible = "renesas,rcar-sata";
 		reg = <0xfc600000 0x2000>;
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 15/19] ARM: shmobile: r7s72100: Add MTU2 device to DT
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add the MTU2 counter to the r7s72100 device tree and make it disabled by
default.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r7s72100.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/r7s72100.dtsi b/arch/arm/boot/dts/r7s72100.dtsi
index bdee225..c902b0b 100644
--- a/arch/arm/boot/dts/r7s72100.dtsi
+++ b/arch/arm/boot/dts/r7s72100.dtsi
@@ -229,6 +229,16 @@
 		status = "disabled";
 	};
 
+	mtu2: timer@fcff0000 {
+		compatible = "renesas,mtu2";
+		reg = <0xfcff0000 0x400>;
+		interrupts = <0 139 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "tgi0a";
+		clocks = <&mstp3_clks R7S72100_CLK_MTU2>;
+		clock-names = "fck";
+		status = "disabled";
+	};
+
 	scif0: serial@e8007000 {
 		compatible = "renesas,scif-r7s72100", "renesas,scif";
 		reg = <0xe8007000 64>;
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 15/19] ARM: shmobile: r7s72100: Add MTU2 device to DT
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add the MTU2 counter to the r7s72100 device tree and make it disabled by
default.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r7s72100.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/r7s72100.dtsi b/arch/arm/boot/dts/r7s72100.dtsi
index bdee225..c902b0b 100644
--- a/arch/arm/boot/dts/r7s72100.dtsi
+++ b/arch/arm/boot/dts/r7s72100.dtsi
@@ -229,6 +229,16 @@
 		status = "disabled";
 	};
 
+	mtu2: timer at fcff0000 {
+		compatible = "renesas,mtu2";
+		reg = <0xfcff0000 0x400>;
+		interrupts = <0 139 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-names = "tgi0a";
+		clocks = <&mstp3_clks R7S72100_CLK_MTU2>;
+		clock-names = "fck";
+		status = "disabled";
+	};
+
 	scif0: serial at e8007000 {
 		compatible = "renesas,scif-r7s72100", "renesas,scif";
 		reg = <0xe8007000 64>;
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 16/19] ARM: shmobile: lager-reference: Enable CMT0 in device tree
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

No more device needs to be added from platform code when booting the
reference platform, remove the now empty r8a7790_add_dt_devices()
function completely.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7790-lager.dts            | 4 ++++
 arch/arm/mach-shmobile/board-lager-reference.c | 2 --
 arch/arm/mach-shmobile/include/mach/r8a7790.h  | 1 -
 arch/arm/mach-shmobile/setup-r8a7790.c         | 7 +------
 4 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts
index 850dff8..32a636f 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -237,6 +237,10 @@
 	};
 };
 
+&cmt0 {
+	status = "ok";
+};
+
 &mmcif1 {
 	pinctrl-0 = <&mmc1_pins>;
 	pinctrl-names = "default";
diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c
index 4393f12..ee6feb9 100644
--- a/arch/arm/mach-shmobile/board-lager-reference.c
+++ b/arch/arm/mach-shmobile/board-lager-reference.c
@@ -90,7 +90,6 @@ static void __init lager_add_du_device(void)
  * devices until they get moved to DT.
  */
 static const struct clk_name clk_names[] __initconst = {
-	{ "cmt0", "fck", "sh-cmt-48-gen2.0" },
 	{ "du0", "du.0", "rcar-du-r8a7790" },
 	{ "du1", "du.1", "rcar-du-r8a7790" },
 	{ "du2", "du.2", "rcar-du-r8a7790" },
@@ -101,7 +100,6 @@ static const struct clk_name clk_names[] __initconst = {
 static void __init lager_add_standard_devices(void)
 {
 	shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false);
-	r8a7790_add_dt_devices();
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
 	lager_add_du_device();
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7790.h b/arch/arm/mach-shmobile/include/mach/r8a7790.h
index 3ebc1f4..9684441 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7790.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7790.h
@@ -29,7 +29,6 @@ enum {
 };
 
 void r8a7790_add_standard_devices(void);
-void r8a7790_add_dt_devices(void);
 void r8a7790_clock_init(void);
 void r8a7790_pinmux_init(void);
 void r8a7790_pm_init(void);
diff --git a/arch/arm/mach-shmobile/setup-r8a7790.c b/arch/arm/mach-shmobile/setup-r8a7790.c
index 80af1d2..37d6eca 100644
--- a/arch/arm/mach-shmobile/setup-r8a7790.c
+++ b/arch/arm/mach-shmobile/setup-r8a7790.c
@@ -279,11 +279,6 @@ static struct resource cmt0_resources[] = {
 					  &cmt##idx##_platform_data,	\
 					  sizeof(struct sh_timer_config))
 
-void __init r8a7790_add_dt_devices(void)
-{
-	r8a7790_register_cmt(0);
-}
-
 void __init r8a7790_add_standard_devices(void)
 {
 	r8a7790_register_scif(0);
@@ -296,7 +291,7 @@ void __init r8a7790_add_standard_devices(void)
 	r8a7790_register_scif(7);
 	r8a7790_register_scif(8);
 	r8a7790_register_scif(9);
-	r8a7790_add_dt_devices();
+	r8a7790_register_cmt(0);
 	r8a7790_register_irqc(0);
 	r8a7790_register_thermal();
 	r8a7790_register_i2c(0);
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 16/19] ARM: shmobile: lager-reference: Enable CMT0 in device tree
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

No more device needs to be added from platform code when booting the
reference platform, remove the now empty r8a7790_add_dt_devices()
function completely.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7790-lager.dts            | 4 ++++
 arch/arm/mach-shmobile/board-lager-reference.c | 2 --
 arch/arm/mach-shmobile/include/mach/r8a7790.h  | 1 -
 arch/arm/mach-shmobile/setup-r8a7790.c         | 7 +------
 4 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts
index 850dff8..32a636f 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -237,6 +237,10 @@
 	};
 };
 
+&cmt0 {
+	status = "ok";
+};
+
 &mmcif1 {
 	pinctrl-0 = <&mmc1_pins>;
 	pinctrl-names = "default";
diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c
index 4393f12..ee6feb9 100644
--- a/arch/arm/mach-shmobile/board-lager-reference.c
+++ b/arch/arm/mach-shmobile/board-lager-reference.c
@@ -90,7 +90,6 @@ static void __init lager_add_du_device(void)
  * devices until they get moved to DT.
  */
 static const struct clk_name clk_names[] __initconst = {
-	{ "cmt0", "fck", "sh-cmt-48-gen2.0" },
 	{ "du0", "du.0", "rcar-du-r8a7790" },
 	{ "du1", "du.1", "rcar-du-r8a7790" },
 	{ "du2", "du.2", "rcar-du-r8a7790" },
@@ -101,7 +100,6 @@ static const struct clk_name clk_names[] __initconst = {
 static void __init lager_add_standard_devices(void)
 {
 	shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false);
-	r8a7790_add_dt_devices();
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
 	lager_add_du_device();
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7790.h b/arch/arm/mach-shmobile/include/mach/r8a7790.h
index 3ebc1f4..9684441 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7790.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7790.h
@@ -29,7 +29,6 @@ enum {
 };
 
 void r8a7790_add_standard_devices(void);
-void r8a7790_add_dt_devices(void);
 void r8a7790_clock_init(void);
 void r8a7790_pinmux_init(void);
 void r8a7790_pm_init(void);
diff --git a/arch/arm/mach-shmobile/setup-r8a7790.c b/arch/arm/mach-shmobile/setup-r8a7790.c
index 80af1d2..37d6eca 100644
--- a/arch/arm/mach-shmobile/setup-r8a7790.c
+++ b/arch/arm/mach-shmobile/setup-r8a7790.c
@@ -279,11 +279,6 @@ static struct resource cmt0_resources[] = {
 					  &cmt##idx##_platform_data,	\
 					  sizeof(struct sh_timer_config))
 
-void __init r8a7790_add_dt_devices(void)
-{
-	r8a7790_register_cmt(0);
-}
-
 void __init r8a7790_add_standard_devices(void)
 {
 	r8a7790_register_scif(0);
@@ -296,7 +291,7 @@ void __init r8a7790_add_standard_devices(void)
 	r8a7790_register_scif(7);
 	r8a7790_register_scif(8);
 	r8a7790_register_scif(9);
-	r8a7790_add_dt_devices();
+	r8a7790_register_cmt(0);
 	r8a7790_register_irqc(0);
 	r8a7790_register_thermal();
 	r8a7790_register_i2c(0);
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 17/19] ARM: shmobile: koelsch-reference: Enable CMT0 in device tree
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

No more device needs to be added from platform code when booting the
reference platform, remove the now empty r8a7791_add_dt_devices()
function completely.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7791-koelsch.dts            | 4 ++++
 arch/arm/mach-shmobile/board-koelsch-reference.c | 2 --
 arch/arm/mach-shmobile/include/mach/r8a7791.h    | 1 -
 arch/arm/mach-shmobile/setup-r8a7791.c           | 7 +------
 4 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts
index 3fe7a7f..1f88332 100644
--- a/arch/arm/boot/dts/r8a7791-koelsch.dts
+++ b/arch/arm/boot/dts/r8a7791-koelsch.dts
@@ -303,6 +303,10 @@
 	};
 };
 
+&cmt0 {
+	status = "ok";
+};
+
 &sata0 {
 	status = "okay";
 };
diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c
index 26189e2..1a73200 100644
--- a/arch/arm/mach-shmobile/board-koelsch-reference.c
+++ b/arch/arm/mach-shmobile/board-koelsch-reference.c
@@ -86,7 +86,6 @@ static void __init koelsch_add_du_device(void)
  * devices until they get moved to DT.
  */
 static const struct clk_name clk_names[] __initconst = {
-	{ "cmt0", "fck", "sh-cmt-48-gen2.0" },
 	{ "du0", "du.0", "rcar-du-r8a7791" },
 	{ "du1", "du.1", "rcar-du-r8a7791" },
 	{ "lvds0", "lvds.0", "rcar-du-r8a7791" },
@@ -95,7 +94,6 @@ static const struct clk_name clk_names[] __initconst = {
 static void __init koelsch_add_standard_devices(void)
 {
 	shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false);
-	r8a7791_add_dt_devices();
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
 	koelsch_add_du_device();
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7791.h b/arch/arm/mach-shmobile/include/mach/r8a7791.h
index 86eae7b..c1bf7ab 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7791.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7791.h
@@ -2,7 +2,6 @@
 #define __ASM_R8A7791_H__
 
 void r8a7791_add_standard_devices(void);
-void r8a7791_add_dt_devices(void);
 void r8a7791_clock_init(void);
 void r8a7791_pinmux_init(void);
 void r8a7791_pm_init(void);
diff --git a/arch/arm/mach-shmobile/setup-r8a7791.c b/arch/arm/mach-shmobile/setup-r8a7791.c
index ddd2fca..a66727e 100644
--- a/arch/arm/mach-shmobile/setup-r8a7791.c
+++ b/arch/arm/mach-shmobile/setup-r8a7791.c
@@ -180,11 +180,6 @@ static const struct resource thermal_resources[] __initconst = {
 					thermal_resources,		\
 					ARRAY_SIZE(thermal_resources))
 
-void __init r8a7791_add_dt_devices(void)
-{
-	r8a7791_register_cmt(0);
-}
-
 void __init r8a7791_add_standard_devices(void)
 {
 	r8a7791_register_scif(0);
@@ -202,7 +197,7 @@ void __init r8a7791_add_standard_devices(void)
 	r8a7791_register_scif(12);
 	r8a7791_register_scif(13);
 	r8a7791_register_scif(14);
-	r8a7791_add_dt_devices();
+	r8a7791_register_cmt(0);
 	r8a7791_register_irqc(0);
 	r8a7791_register_thermal();
 }
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 17/19] ARM: shmobile: koelsch-reference: Enable CMT0 in device tree
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

No more device needs to be added from platform code when booting the
reference platform, remove the now empty r8a7791_add_dt_devices()
function completely.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7791-koelsch.dts            | 4 ++++
 arch/arm/mach-shmobile/board-koelsch-reference.c | 2 --
 arch/arm/mach-shmobile/include/mach/r8a7791.h    | 1 -
 arch/arm/mach-shmobile/setup-r8a7791.c           | 7 +------
 4 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts
index 3fe7a7f..1f88332 100644
--- a/arch/arm/boot/dts/r8a7791-koelsch.dts
+++ b/arch/arm/boot/dts/r8a7791-koelsch.dts
@@ -303,6 +303,10 @@
 	};
 };
 
+&cmt0 {
+	status = "ok";
+};
+
 &sata0 {
 	status = "okay";
 };
diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c
index 26189e2..1a73200 100644
--- a/arch/arm/mach-shmobile/board-koelsch-reference.c
+++ b/arch/arm/mach-shmobile/board-koelsch-reference.c
@@ -86,7 +86,6 @@ static void __init koelsch_add_du_device(void)
  * devices until they get moved to DT.
  */
 static const struct clk_name clk_names[] __initconst = {
-	{ "cmt0", "fck", "sh-cmt-48-gen2.0" },
 	{ "du0", "du.0", "rcar-du-r8a7791" },
 	{ "du1", "du.1", "rcar-du-r8a7791" },
 	{ "lvds0", "lvds.0", "rcar-du-r8a7791" },
@@ -95,7 +94,6 @@ static const struct clk_name clk_names[] __initconst = {
 static void __init koelsch_add_standard_devices(void)
 {
 	shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false);
-	r8a7791_add_dt_devices();
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
 	koelsch_add_du_device();
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7791.h b/arch/arm/mach-shmobile/include/mach/r8a7791.h
index 86eae7b..c1bf7ab 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7791.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7791.h
@@ -2,7 +2,6 @@
 #define __ASM_R8A7791_H__
 
 void r8a7791_add_standard_devices(void);
-void r8a7791_add_dt_devices(void);
 void r8a7791_clock_init(void);
 void r8a7791_pinmux_init(void);
 void r8a7791_pm_init(void);
diff --git a/arch/arm/mach-shmobile/setup-r8a7791.c b/arch/arm/mach-shmobile/setup-r8a7791.c
index ddd2fca..a66727e 100644
--- a/arch/arm/mach-shmobile/setup-r8a7791.c
+++ b/arch/arm/mach-shmobile/setup-r8a7791.c
@@ -180,11 +180,6 @@ static const struct resource thermal_resources[] __initconst = {
 					thermal_resources,		\
 					ARRAY_SIZE(thermal_resources))
 
-void __init r8a7791_add_dt_devices(void)
-{
-	r8a7791_register_cmt(0);
-}
-
 void __init r8a7791_add_standard_devices(void)
 {
 	r8a7791_register_scif(0);
@@ -202,7 +197,7 @@ void __init r8a7791_add_standard_devices(void)
 	r8a7791_register_scif(12);
 	r8a7791_register_scif(13);
 	r8a7791_register_scif(14);
-	r8a7791_add_dt_devices();
+	r8a7791_register_cmt(0);
 	r8a7791_register_irqc(0);
 	r8a7791_register_thermal();
 }
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 18/19] ARM: shmobile: marzen-reference: Enable TMU0 in device tree
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

No more device needs to be added from platform code when booting the
reference platform, remove the now empty
r8a7779_add_standard_devices_dt() function completely.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7779-marzen.dts            |  4 ++++
 arch/arm/mach-shmobile/board-marzen-reference.c | 10 ----------
 arch/arm/mach-shmobile/include/mach/r8a7779.h   |  1 -
 arch/arm/mach-shmobile/setup-r8a7779.c          | 17 +++++------------
 4 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7779-marzen.dts b/arch/arm/boot/dts/r8a7779-marzen.dts
index 20b1768..6025822 100644
--- a/arch/arm/boot/dts/r8a7779-marzen.dts
+++ b/arch/arm/boot/dts/r8a7779-marzen.dts
@@ -78,6 +78,10 @@
 	clock-frequency = <31250000>;
 };
 
+&tmu0 {
+	status = "okay";
+};
+
 &pfc {
 	lan0_pins: lan0 {
 		intc {
diff --git a/arch/arm/mach-shmobile/board-marzen-reference.c b/arch/arm/mach-shmobile/board-marzen-reference.c
index 670e48a..29bd384 100644
--- a/arch/arm/mach-shmobile/board-marzen-reference.c
+++ b/arch/arm/mach-shmobile/board-marzen-reference.c
@@ -35,18 +35,8 @@ static void __init marzen_init_timer(void)
 	clocksource_of_init();
 }
 
-/*
- * This is a really crude hack to provide clkdev support to platform
- * devices until they get moved to DT.
- */
-static const struct clk_name clk_names[] __initconst = {
-	{ "tmu0", "fck", "sh-tmu.0" },
-};
-
 static void __init marzen_init(void)
 {
-	shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false);
-	r8a7779_add_standard_devices_dt();
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 	r8a7779_init_irq_extpin_dt(1); /* IRQ1 as individual interrupt */
 }
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7779.h b/arch/arm/mach-shmobile/include/mach/r8a7779.h
index e443c54..9e8c68e 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7779.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7779.h
@@ -28,7 +28,6 @@ extern void r8a7779_map_io(void);
 extern void r8a7779_earlytimer_init(void);
 extern void r8a7779_add_early_devices(void);
 extern void r8a7779_add_standard_devices(void);
-extern void r8a7779_add_standard_devices_dt(void);
 extern void r8a7779_init_late(void);
 extern u32 r8a7779_read_mode_pins(void);
 extern void r8a7779_clock_init(void);
diff --git a/arch/arm/mach-shmobile/setup-r8a7779.c b/arch/arm/mach-shmobile/setup-r8a7779.c
index e0050ab0..dcb8d18 100644
--- a/arch/arm/mach-shmobile/setup-r8a7779.c
+++ b/arch/arm/mach-shmobile/setup-r8a7779.c
@@ -639,7 +639,7 @@ static void __init r8a7779_register_hpb_dmae(void)
 					  sizeof(dma_platform_data));
 }
 
-static struct platform_device *r8a7779_devices_dt[] __initdata = {
+static struct platform_device *r8a7779_early_devices[] __initdata = {
 	&tmu0_device,
 };
 
@@ -667,8 +667,8 @@ void __init r8a7779_add_standard_devices(void)
 
 	r8a7779_init_pm_domains();
 
-	platform_add_devices(r8a7779_devices_dt,
-			    ARRAY_SIZE(r8a7779_devices_dt));
+	platform_add_devices(r8a7779_early_devices,
+			    ARRAY_SIZE(r8a7779_early_devices));
 	platform_add_devices(r8a7779_standard_devices,
 			    ARRAY_SIZE(r8a7779_standard_devices));
 	r8a7779_register_hpb_dmae();
@@ -676,8 +676,8 @@ void __init r8a7779_add_standard_devices(void)
 
 void __init r8a7779_add_early_devices(void)
 {
-	early_platform_add_devices(r8a7779_devices_dt,
-				   ARRAY_SIZE(r8a7779_devices_dt));
+	early_platform_add_devices(r8a7779_early_devices,
+				   ARRAY_SIZE(r8a7779_early_devices));
 
 	/* Early serial console setup is not included here due to
 	 * memory map collisions. The SCIF serial ports in r8a7779
@@ -737,12 +737,6 @@ void __init r8a7779_init_irq_dt(void)
 	__raw_writel(0x003fee3f, INT2SMSKCR4);
 }
 
-void __init r8a7779_add_standard_devices_dt(void)
-{
-	platform_add_devices(r8a7779_devices_dt,
-			     ARRAY_SIZE(r8a7779_devices_dt));
-}
-
 #define MODEMR		0xffcc0020
 
 u32 __init r8a7779_read_mode_pins(void)
@@ -771,7 +765,6 @@ DT_MACHINE_START(R8A7779_DT, "Generic R8A7779 (Flattened Device Tree)")
 	.init_early	= shmobile_init_delay,
 	.nr_irqs	= NR_IRQS_LEGACY,
 	.init_irq	= r8a7779_init_irq_dt,
-	.init_machine	= r8a7779_add_standard_devices_dt,
 	.init_late	= r8a7779_init_late,
 	.dt_compat	= r8a7779_compat_dt,
 MACHINE_END
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 18/19] ARM: shmobile: marzen-reference: Enable TMU0 in device tree
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

No more device needs to be added from platform code when booting the
reference platform, remove the now empty
r8a7779_add_standard_devices_dt() function completely.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r8a7779-marzen.dts            |  4 ++++
 arch/arm/mach-shmobile/board-marzen-reference.c | 10 ----------
 arch/arm/mach-shmobile/include/mach/r8a7779.h   |  1 -
 arch/arm/mach-shmobile/setup-r8a7779.c          | 17 +++++------------
 4 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7779-marzen.dts b/arch/arm/boot/dts/r8a7779-marzen.dts
index 20b1768..6025822 100644
--- a/arch/arm/boot/dts/r8a7779-marzen.dts
+++ b/arch/arm/boot/dts/r8a7779-marzen.dts
@@ -78,6 +78,10 @@
 	clock-frequency = <31250000>;
 };
 
+&tmu0 {
+	status = "okay";
+};
+
 &pfc {
 	lan0_pins: lan0 {
 		intc {
diff --git a/arch/arm/mach-shmobile/board-marzen-reference.c b/arch/arm/mach-shmobile/board-marzen-reference.c
index 670e48a..29bd384 100644
--- a/arch/arm/mach-shmobile/board-marzen-reference.c
+++ b/arch/arm/mach-shmobile/board-marzen-reference.c
@@ -35,18 +35,8 @@ static void __init marzen_init_timer(void)
 	clocksource_of_init();
 }
 
-/*
- * This is a really crude hack to provide clkdev support to platform
- * devices until they get moved to DT.
- */
-static const struct clk_name clk_names[] __initconst = {
-	{ "tmu0", "fck", "sh-tmu.0" },
-};
-
 static void __init marzen_init(void)
 {
-	shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false);
-	r8a7779_add_standard_devices_dt();
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 	r8a7779_init_irq_extpin_dt(1); /* IRQ1 as individual interrupt */
 }
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7779.h b/arch/arm/mach-shmobile/include/mach/r8a7779.h
index e443c54..9e8c68e 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7779.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7779.h
@@ -28,7 +28,6 @@ extern void r8a7779_map_io(void);
 extern void r8a7779_earlytimer_init(void);
 extern void r8a7779_add_early_devices(void);
 extern void r8a7779_add_standard_devices(void);
-extern void r8a7779_add_standard_devices_dt(void);
 extern void r8a7779_init_late(void);
 extern u32 r8a7779_read_mode_pins(void);
 extern void r8a7779_clock_init(void);
diff --git a/arch/arm/mach-shmobile/setup-r8a7779.c b/arch/arm/mach-shmobile/setup-r8a7779.c
index e0050ab0..dcb8d18 100644
--- a/arch/arm/mach-shmobile/setup-r8a7779.c
+++ b/arch/arm/mach-shmobile/setup-r8a7779.c
@@ -639,7 +639,7 @@ static void __init r8a7779_register_hpb_dmae(void)
 					  sizeof(dma_platform_data));
 }
 
-static struct platform_device *r8a7779_devices_dt[] __initdata = {
+static struct platform_device *r8a7779_early_devices[] __initdata = {
 	&tmu0_device,
 };
 
@@ -667,8 +667,8 @@ void __init r8a7779_add_standard_devices(void)
 
 	r8a7779_init_pm_domains();
 
-	platform_add_devices(r8a7779_devices_dt,
-			    ARRAY_SIZE(r8a7779_devices_dt));
+	platform_add_devices(r8a7779_early_devices,
+			    ARRAY_SIZE(r8a7779_early_devices));
 	platform_add_devices(r8a7779_standard_devices,
 			    ARRAY_SIZE(r8a7779_standard_devices));
 	r8a7779_register_hpb_dmae();
@@ -676,8 +676,8 @@ void __init r8a7779_add_standard_devices(void)
 
 void __init r8a7779_add_early_devices(void)
 {
-	early_platform_add_devices(r8a7779_devices_dt,
-				   ARRAY_SIZE(r8a7779_devices_dt));
+	early_platform_add_devices(r8a7779_early_devices,
+				   ARRAY_SIZE(r8a7779_early_devices));
 
 	/* Early serial console setup is not included here due to
 	 * memory map collisions. The SCIF serial ports in r8a7779
@@ -737,12 +737,6 @@ void __init r8a7779_init_irq_dt(void)
 	__raw_writel(0x003fee3f, INT2SMSKCR4);
 }
 
-void __init r8a7779_add_standard_devices_dt(void)
-{
-	platform_add_devices(r8a7779_devices_dt,
-			     ARRAY_SIZE(r8a7779_devices_dt));
-}
-
 #define MODEMR		0xffcc0020
 
 u32 __init r8a7779_read_mode_pins(void)
@@ -771,7 +765,6 @@ DT_MACHINE_START(R8A7779_DT, "Generic R8A7779 (Flattened Device Tree)")
 	.init_early	= shmobile_init_delay,
 	.nr_irqs	= NR_IRQS_LEGACY,
 	.init_irq	= r8a7779_init_irq_dt,
-	.init_machine	= r8a7779_add_standard_devices_dt,
 	.init_late	= r8a7779_init_late,
 	.dt_compat	= r8a7779_compat_dt,
 MACHINE_END
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 19/19] ARM: shmobile: genmai-reference: Enable MTU2 in device tree
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-14 16:23   ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

No more device needs to be added from platform code when booting the
reference platform, move MTU2 registration from setup-r7s72100.c to
board-genmai.c and remove the now empty r7s72100_add_dt_devices()
function.

As the genmai_add_standard_devices() function is now identical to the
default init_machine implementation, remove it as well.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r7s72100-genmai.dts           |  4 ++++
 arch/arm/mach-shmobile/board-genmai-reference.c | 16 ----------------
 arch/arm/mach-shmobile/board-genmai.c           | 14 +++++++++++++-
 arch/arm/mach-shmobile/include/mach/r7s72100.h  |  1 -
 arch/arm/mach-shmobile/setup-r7s72100.c         | 21 ---------------------
 5 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/arch/arm/boot/dts/r7s72100-genmai.dts b/arch/arm/boot/dts/r7s72100-genmai.dts
index 56849b5..a352734 100644
--- a/arch/arm/boot/dts/r7s72100-genmai.dts
+++ b/arch/arm/boot/dts/r7s72100-genmai.dts
@@ -43,6 +43,10 @@
 	clock-frequency = <48000000>;
 };
 
+&mtu2 {
+	status = "ok";
+};
+
 &i2c2 {
 	status = "okay";
 	clock-frequency = <400000>;
diff --git a/arch/arm/mach-shmobile/board-genmai-reference.c b/arch/arm/mach-shmobile/board-genmai-reference.c
index 627539e..a80df03 100644
--- a/arch/arm/mach-shmobile/board-genmai-reference.c
+++ b/arch/arm/mach-shmobile/board-genmai-reference.c
@@ -26,21 +26,6 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
-/*
- * This is a really crude hack to provide clkdev support to platform
- * devices until they get moved to DT.
- */
-static const struct clk_name clk_names[] = {
-	{ "mtu2", "fck", "sh-mtu2" },
-};
-
-static void __init genmai_add_standard_devices(void)
-{
-	shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), true);
-	r7s72100_add_dt_devices();
-	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
-}
-
 static const char * const genmai_boards_compat_dt[] __initconst = {
 	"renesas,genmai",
 	NULL,
@@ -48,6 +33,5 @@ static const char * const genmai_boards_compat_dt[] __initconst = {
 
 DT_MACHINE_START(GENMAI_DT, "genmai")
 	.init_early	= shmobile_init_delay,
-	.init_machine	= genmai_add_standard_devices,
 	.dt_compat	= genmai_boards_compat_dt,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-genmai.c b/arch/arm/mach-shmobile/board-genmai.c
index 11f3cd1..bd0785f 100644
--- a/arch/arm/mach-shmobile/board-genmai.c
+++ b/arch/arm/mach-shmobile/board-genmai.c
@@ -23,6 +23,7 @@
 #include <linux/platform_device.h>
 #include <linux/serial_sci.h>
 #include <linux/sh_eth.h>
+#include <linux/sh_timer.h>
 #include <linux/spi/rspi.h>
 #include <linux/spi/spi.h>
 #include <mach/common.h>
@@ -124,10 +125,21 @@ R7S72100_SCIF(7, 0xe800a800, gic_iid(249));
 					  &scif##index##_platform_data,	       \
 					  sizeof(scif##index##_platform_data))
 
+static struct resource mtu2_resources[] __initdata = {
+	DEFINE_RES_MEM(0xfcff0000, 0x400),
+	DEFINE_RES_IRQ_NAMED(gic_iid(139), "tgi0a"),
+};
+
+#define r7s72100_register_mtu2()					\
+	platform_device_register_resndata(&platform_bus, "sh-mtu2",	\
+					  -1, mtu2_resources,		\
+					  ARRAY_SIZE(mtu2_resources),	\
+					  NULL, 0)
+
 static void __init genmai_add_standard_devices(void)
 {
 	r7s72100_clock_init();
-	r7s72100_add_dt_devices();
+	r7s72100_register_mtu2();
 
 	platform_device_register_full(&ether_info);
 
diff --git a/arch/arm/mach-shmobile/include/mach/r7s72100.h b/arch/arm/mach-shmobile/include/mach/r7s72100.h
index efb723c..321ae4e 100644
--- a/arch/arm/mach-shmobile/include/mach/r7s72100.h
+++ b/arch/arm/mach-shmobile/include/mach/r7s72100.h
@@ -1,7 +1,6 @@
 #ifndef __ASM_R7S72100_H__
 #define __ASM_R7S72100_H__
 
-void r7s72100_add_dt_devices(void);
 void r7s72100_clock_init(void);
 
 #endif /* __ASM_R7S72100_H__ */
diff --git a/arch/arm/mach-shmobile/setup-r7s72100.c b/arch/arm/mach-shmobile/setup-r7s72100.c
index 427ae1c..a55c13b 100644
--- a/arch/arm/mach-shmobile/setup-r7s72100.c
+++ b/arch/arm/mach-shmobile/setup-r7s72100.c
@@ -18,31 +18,10 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <linux/irq.h>
-#include <linux/kernel.h>
 #include <linux/of_platform.h>
-#include <linux/sh_timer.h>
 #include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/r7s72100.h>
 #include <asm/mach/arch.h>
 
-static struct resource mtu2_resources[] __initdata = {
-	DEFINE_RES_MEM(0xfcff0000, 0x400),
-	DEFINE_RES_IRQ_NAMED(gic_iid(139), "tgi0a"),
-};
-
-#define r7s72100_register_mtu2()					\
-	platform_device_register_resndata(&platform_bus, "sh-mtu2",	\
-					  -1, mtu2_resources,		\
-					  ARRAY_SIZE(mtu2_resources),	\
-					  NULL, 0)
-
-void __init r7s72100_add_dt_devices(void)
-{
-	r7s72100_register_mtu2();
-}
-
 #ifdef CONFIG_USE_OF
 static const char *r7s72100_boards_compat_dt[] __initdata = {
 	"renesas,r7s72100",
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 19/19] ARM: shmobile: genmai-reference: Enable MTU2 in device tree
@ 2014-06-14 16:23   ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-14 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

No more device needs to be added from platform code when booting the
reference platform, move MTU2 registration from setup-r7s72100.c to
board-genmai.c and remove the now empty r7s72100_add_dt_devices()
function.

As the genmai_add_standard_devices() function is now identical to the
default init_machine implementation, remove it as well.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 arch/arm/boot/dts/r7s72100-genmai.dts           |  4 ++++
 arch/arm/mach-shmobile/board-genmai-reference.c | 16 ----------------
 arch/arm/mach-shmobile/board-genmai.c           | 14 +++++++++++++-
 arch/arm/mach-shmobile/include/mach/r7s72100.h  |  1 -
 arch/arm/mach-shmobile/setup-r7s72100.c         | 21 ---------------------
 5 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/arch/arm/boot/dts/r7s72100-genmai.dts b/arch/arm/boot/dts/r7s72100-genmai.dts
index 56849b5..a352734 100644
--- a/arch/arm/boot/dts/r7s72100-genmai.dts
+++ b/arch/arm/boot/dts/r7s72100-genmai.dts
@@ -43,6 +43,10 @@
 	clock-frequency = <48000000>;
 };
 
+&mtu2 {
+	status = "ok";
+};
+
 &i2c2 {
 	status = "okay";
 	clock-frequency = <400000>;
diff --git a/arch/arm/mach-shmobile/board-genmai-reference.c b/arch/arm/mach-shmobile/board-genmai-reference.c
index 627539e..a80df03 100644
--- a/arch/arm/mach-shmobile/board-genmai-reference.c
+++ b/arch/arm/mach-shmobile/board-genmai-reference.c
@@ -26,21 +26,6 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
-/*
- * This is a really crude hack to provide clkdev support to platform
- * devices until they get moved to DT.
- */
-static const struct clk_name clk_names[] = {
-	{ "mtu2", "fck", "sh-mtu2" },
-};
-
-static void __init genmai_add_standard_devices(void)
-{
-	shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), true);
-	r7s72100_add_dt_devices();
-	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
-}
-
 static const char * const genmai_boards_compat_dt[] __initconst = {
 	"renesas,genmai",
 	NULL,
@@ -48,6 +33,5 @@ static const char * const genmai_boards_compat_dt[] __initconst = {
 
 DT_MACHINE_START(GENMAI_DT, "genmai")
 	.init_early	= shmobile_init_delay,
-	.init_machine	= genmai_add_standard_devices,
 	.dt_compat	= genmai_boards_compat_dt,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-genmai.c b/arch/arm/mach-shmobile/board-genmai.c
index 11f3cd1..bd0785f 100644
--- a/arch/arm/mach-shmobile/board-genmai.c
+++ b/arch/arm/mach-shmobile/board-genmai.c
@@ -23,6 +23,7 @@
 #include <linux/platform_device.h>
 #include <linux/serial_sci.h>
 #include <linux/sh_eth.h>
+#include <linux/sh_timer.h>
 #include <linux/spi/rspi.h>
 #include <linux/spi/spi.h>
 #include <mach/common.h>
@@ -124,10 +125,21 @@ R7S72100_SCIF(7, 0xe800a800, gic_iid(249));
 					  &scif##index##_platform_data,	       \
 					  sizeof(scif##index##_platform_data))
 
+static struct resource mtu2_resources[] __initdata = {
+	DEFINE_RES_MEM(0xfcff0000, 0x400),
+	DEFINE_RES_IRQ_NAMED(gic_iid(139), "tgi0a"),
+};
+
+#define r7s72100_register_mtu2()					\
+	platform_device_register_resndata(&platform_bus, "sh-mtu2",	\
+					  -1, mtu2_resources,		\
+					  ARRAY_SIZE(mtu2_resources),	\
+					  NULL, 0)
+
 static void __init genmai_add_standard_devices(void)
 {
 	r7s72100_clock_init();
-	r7s72100_add_dt_devices();
+	r7s72100_register_mtu2();
 
 	platform_device_register_full(&ether_info);
 
diff --git a/arch/arm/mach-shmobile/include/mach/r7s72100.h b/arch/arm/mach-shmobile/include/mach/r7s72100.h
index efb723c..321ae4e 100644
--- a/arch/arm/mach-shmobile/include/mach/r7s72100.h
+++ b/arch/arm/mach-shmobile/include/mach/r7s72100.h
@@ -1,7 +1,6 @@
 #ifndef __ASM_R7S72100_H__
 #define __ASM_R7S72100_H__
 
-void r7s72100_add_dt_devices(void);
 void r7s72100_clock_init(void);
 
 #endif /* __ASM_R7S72100_H__ */
diff --git a/arch/arm/mach-shmobile/setup-r7s72100.c b/arch/arm/mach-shmobile/setup-r7s72100.c
index 427ae1c..a55c13b 100644
--- a/arch/arm/mach-shmobile/setup-r7s72100.c
+++ b/arch/arm/mach-shmobile/setup-r7s72100.c
@@ -18,31 +18,10 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <linux/irq.h>
-#include <linux/kernel.h>
 #include <linux/of_platform.h>
-#include <linux/sh_timer.h>
 #include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/r7s72100.h>
 #include <asm/mach/arch.h>
 
-static struct resource mtu2_resources[] __initdata = {
-	DEFINE_RES_MEM(0xfcff0000, 0x400),
-	DEFINE_RES_IRQ_NAMED(gic_iid(139), "tgi0a"),
-};
-
-#define r7s72100_register_mtu2()					\
-	platform_device_register_resndata(&platform_bus, "sh-mtu2",	\
-					  -1, mtu2_resources,		\
-					  ARRAY_SIZE(mtu2_resources),	\
-					  NULL, 0)
-
-void __init r7s72100_add_dt_devices(void)
-{
-	r7s72100_register_mtu2();
-}
-
 #ifdef CONFIG_USE_OF
 static const char *r7s72100_boards_compat_dt[] __initdata = {
 	"renesas,r7s72100",
-- 
1.8.5.5

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 12/19] ARM: shmobile: r8a7790: Add CMT devices to DT
  2014-06-14 16:23   ` Laurent Pinchart
@ 2014-06-14 16:54     ` Sergei Shtylyov
  -1 siblings, 0 replies; 76+ messages in thread
From: Sergei Shtylyov @ 2014-06-14 16:54 UTC (permalink / raw)
  To: linux-arm-kernel

Hello.

On 06/14/2014 08:23 PM, Laurent Pinchart wrote:

> Add the CMT0 and CMT1 counters to the r8a7790 device tree and make them
> disabled by default.

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>   arch/arm/boot/dts/r8a7790.dtsi | 34 ++++++++++++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)

> diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
> index 29907c9..cc32ac5 100644
> --- a/arch/arm/boot/dts/r8a7790.dtsi
> +++ b/arch/arm/boot/dts/r8a7790.dtsi
> @@ -206,6 +206,40 @@
>   			     <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
>   	};
>
> +	cmt0: timer@ffca0000 {
> +		compatible = "renesas,cmt-48-gen2";
> +		reg = <0 0xffca0000 0 0x1004>;
> +		interrupt-parent = <&gic>;

   This prop is inherited from the root node, so unneeded here.

> +		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
> +		clock-names = "fck";
> +
> +		renesas,channels-mask = <0x60>;
> +
> +		status = "disabled";
> +	};
> +
> +	cmt1: timer@e6130000 {
> +		compatible = "renesas,cmt-48-gen2";
> +		reg = <0 0xe6130000 0 0x1004>;
> +		interrupt-parent = <&gic>;

    Likewise.

WBR, Sergei


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 12/19] ARM: shmobile: r8a7790: Add CMT devices to DT
@ 2014-06-14 16:54     ` Sergei Shtylyov
  0 siblings, 0 replies; 76+ messages in thread
From: Sergei Shtylyov @ 2014-06-14 16:54 UTC (permalink / raw)
  To: linux-arm-kernel

Hello.

On 06/14/2014 08:23 PM, Laurent Pinchart wrote:

> Add the CMT0 and CMT1 counters to the r8a7790 device tree and make them
> disabled by default.

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>   arch/arm/boot/dts/r8a7790.dtsi | 34 ++++++++++++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)

> diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
> index 29907c9..cc32ac5 100644
> --- a/arch/arm/boot/dts/r8a7790.dtsi
> +++ b/arch/arm/boot/dts/r8a7790.dtsi
> @@ -206,6 +206,40 @@
>   			     <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
>   	};
>
> +	cmt0: timer at ffca0000 {
> +		compatible = "renesas,cmt-48-gen2";
> +		reg = <0 0xffca0000 0 0x1004>;
> +		interrupt-parent = <&gic>;

   This prop is inherited from the root node, so unneeded here.

> +		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
> +		clock-names = "fck";
> +
> +		renesas,channels-mask = <0x60>;
> +
> +		status = "disabled";
> +	};
> +
> +	cmt1: timer at e6130000 {
> +		compatible = "renesas,cmt-48-gen2";
> +		reg = <0 0xe6130000 0 0x1004>;
> +		interrupt-parent = <&gic>;

    Likewise.

WBR, Sergei

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 13/19] ARM: shmobile: r8a7791: Add CMT devices to DT
  2014-06-14 16:23   ` Laurent Pinchart
@ 2014-06-14 16:55     ` Sergei Shtylyov
  -1 siblings, 0 replies; 76+ messages in thread
From: Sergei Shtylyov @ 2014-06-14 16:55 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/14/2014 08:23 PM, Laurent Pinchart wrote:

> Add the CMT0 and CMT1 counters to the r8a7791 device tree and make them
> disabled by default.

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>   arch/arm/boot/dts/r8a7791.dtsi | 34 ++++++++++++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)

> diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
> index 380d058..b56a995 100644
> --- a/arch/arm/boot/dts/r8a7791.dtsi
> +++ b/arch/arm/boot/dts/r8a7791.dtsi
> @@ -189,6 +189,40 @@
>   			     <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
>   	};
>
> +	cmt0: timer@ffca0000 {
> +		compatible = "renesas,cmt-48-gen2";
> +		reg = <0 0xffca0000 0 0x1004>;
> +		interrupt-parent = <&gic>;

    This prop inherited from the root node, no need to specify it here.

> +		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp1_clks R8A7791_CLK_CMT0>;
> +		clock-names = "fck";
> +
> +		renesas,channels-mask = <0x60>;
> +
> +		status = "disabled";
> +	};
> +
> +	cmt1: timer@e6130000 {
> +		compatible = "renesas,cmt-48-gen2";
> +		reg = <0 0xe6130000 0 0x1004>;
> +		interrupt-parent = <&gic>;

    Likewise.

WBR, Sergei


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 13/19] ARM: shmobile: r8a7791: Add CMT devices to DT
@ 2014-06-14 16:55     ` Sergei Shtylyov
  0 siblings, 0 replies; 76+ messages in thread
From: Sergei Shtylyov @ 2014-06-14 16:55 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/14/2014 08:23 PM, Laurent Pinchart wrote:

> Add the CMT0 and CMT1 counters to the r8a7791 device tree and make them
> disabled by default.

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>   arch/arm/boot/dts/r8a7791.dtsi | 34 ++++++++++++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)

> diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
> index 380d058..b56a995 100644
> --- a/arch/arm/boot/dts/r8a7791.dtsi
> +++ b/arch/arm/boot/dts/r8a7791.dtsi
> @@ -189,6 +189,40 @@
>   			     <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
>   	};
>
> +	cmt0: timer at ffca0000 {
> +		compatible = "renesas,cmt-48-gen2";
> +		reg = <0 0xffca0000 0 0x1004>;
> +		interrupt-parent = <&gic>;

    This prop inherited from the root node, no need to specify it here.

> +		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp1_clks R8A7791_CLK_CMT0>;
> +		clock-names = "fck";
> +
> +		renesas,channels-mask = <0x60>;
> +
> +		status = "disabled";
> +	};
> +
> +	cmt1: timer at e6130000 {
> +		compatible = "renesas,cmt-48-gen2";
> +		reg = <0 0xe6130000 0 0x1004>;
> +		interrupt-parent = <&gic>;

    Likewise.

WBR, Sergei

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 11/19] clocksource: sh_mtu2: Add DT support
  2014-06-14 16:23   ` Laurent Pinchart
@ 2014-06-14 17:00     ` Sergei Shtylyov
  -1 siblings, 0 replies; 76+ messages in thread
From: Sergei Shtylyov @ 2014-06-14 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/14/2014 08:23 PM, Laurent Pinchart wrote:

> Document DT bindings and parse them in the MTU2 driver.

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Tested-by: Wolfram Sang <wsa@sang-engineering.com>
> ---
>   .../devicetree/bindings/timer/renesas,mtu2.txt     | 40 ++++++++++++++++++++++
>   drivers/clocksource/sh_mtu2.c                      |  8 +++++
>   2 files changed, 48 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/timer/renesas,mtu2.txt

> diff --git a/Documentation/devicetree/bindings/timer/renesas,mtu2.txt b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
> new file mode 100644
> index 0000000..c5dd032
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
> @@ -0,0 +1,40 @@
> +* Renesas R-Car Multi-Function Timer Pulse Unit 2 (MTU2)
> +
> +The MTU2 is a multi-purpose, multi-channel timer/counter with configurable
> +clock inputs and programmable compare match.
> +
> +Channels share hardware resources but their counter and compare match value
> +are independent. The MTU2 hardware supports five channels indexed from 0 to 4.
> +
> +Required Properties:
> +
> +  - compatible: must contain "renesas,mtu2"
> +
> +  - reg: base address and length of the registers block for the timer module.
> +
> +  - interrupt-parent, interrupts: interrupt specifiers for the timer, one for
> +    each entry in interrupt-names.

    The "interrupt-parent" has never been a required property, it can and 
should be inherited from an upper level node.

[...]

> diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
> index ebdf9d1..79387af 100644
> --- a/drivers/clocksource/sh_mtu2.c
> +++ b/drivers/clocksource/sh_mtu2.c
[...]
> @@ -502,11 +503,18 @@ static const struct platform_device_id sh_mtu2_id_table[] = {
>   };
>   MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table);
>
> +static const struct of_device_id sh_mtu2_of_table[] = {
> +	{ .compatible = "renesas,mtu2" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, sh_mtu2_of_table);
> +
>   static struct platform_driver sh_mtu2_device_driver = {
>   	.probe		= sh_mtu2_probe,
>   	.remove		= sh_mtu2_remove,
>   	.driver		= {
>   		.name	= "sh_mtu2",
> +		.of_match_table = of_match_ptr(sh_mtu2_of_table),

    No need for of_match_ptr() since the table us not protected by #ifdef 
CONFIG_OF...

WBR, Sergei


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 11/19] clocksource: sh_mtu2: Add DT support
@ 2014-06-14 17:00     ` Sergei Shtylyov
  0 siblings, 0 replies; 76+ messages in thread
From: Sergei Shtylyov @ 2014-06-14 17:00 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/14/2014 08:23 PM, Laurent Pinchart wrote:

> Document DT bindings and parse them in the MTU2 driver.

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Tested-by: Wolfram Sang <wsa@sang-engineering.com>
> ---
>   .../devicetree/bindings/timer/renesas,mtu2.txt     | 40 ++++++++++++++++++++++
>   drivers/clocksource/sh_mtu2.c                      |  8 +++++
>   2 files changed, 48 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/timer/renesas,mtu2.txt

> diff --git a/Documentation/devicetree/bindings/timer/renesas,mtu2.txt b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
> new file mode 100644
> index 0000000..c5dd032
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
> @@ -0,0 +1,40 @@
> +* Renesas R-Car Multi-Function Timer Pulse Unit 2 (MTU2)
> +
> +The MTU2 is a multi-purpose, multi-channel timer/counter with configurable
> +clock inputs and programmable compare match.
> +
> +Channels share hardware resources but their counter and compare match value
> +are independent. The MTU2 hardware supports five channels indexed from 0 to 4.
> +
> +Required Properties:
> +
> +  - compatible: must contain "renesas,mtu2"
> +
> +  - reg: base address and length of the registers block for the timer module.
> +
> +  - interrupt-parent, interrupts: interrupt specifiers for the timer, one for
> +    each entry in interrupt-names.

    The "interrupt-parent" has never been a required property, it can and 
should be inherited from an upper level node.

[...]

> diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
> index ebdf9d1..79387af 100644
> --- a/drivers/clocksource/sh_mtu2.c
> +++ b/drivers/clocksource/sh_mtu2.c
[...]
> @@ -502,11 +503,18 @@ static const struct platform_device_id sh_mtu2_id_table[] = {
>   };
>   MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table);
>
> +static const struct of_device_id sh_mtu2_of_table[] = {
> +	{ .compatible = "renesas,mtu2" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, sh_mtu2_of_table);
> +
>   static struct platform_driver sh_mtu2_device_driver = {
>   	.probe		= sh_mtu2_probe,
>   	.remove		= sh_mtu2_remove,
>   	.driver		= {
>   		.name	= "sh_mtu2",
> +		.of_match_table = of_match_ptr(sh_mtu2_of_table),

    No need for of_match_ptr() since the table us not protected by #ifdef 
CONFIG_OF...

WBR, Sergei

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 10/19] clocksource: sh_tmu: Add DT support
  2014-06-14 16:23   ` Laurent Pinchart
@ 2014-06-16  8:34     ` Simon Horman
  -1 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16  8:34 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Laurent,

thanks for your patch.

On Sat, Jun 14, 2014 at 06:23:32PM +0200, Laurent Pinchart wrote:
> Document DT bindings and parse them in the TMU driver.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

[snip]

> diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
> index ef8fb0b..2ece4ab 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,46 @@ 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->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) {
> +		struct sh_timer_config *cfg = pdev->dev.platform_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)) {

[snip]

I had a bit of trouble running this code and after some investigation
it seems to me that in the case of using DT id will be NULL and
thus things do not go well when id->driver_data is accessed.

The following incremental patch resolved the problem for me.

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 2ece4ab..3f90927 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -523,6 +523,8 @@ static int sh_tmu_parse_dt(struct sh_tmu_device *tmu)
 		return -EINVAL;
 	}
 
+	tmu->model = SH_TMU;
+
 	return 0;
 }
 
@@ -533,7 +535,6 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 	int ret;
 
 	tmu->pdev = pdev;
-	tmu->model = id->driver_data;
 
 	raw_spin_lock_init(&tmu->lock);
 
@@ -545,6 +546,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 		struct sh_timer_config *cfg = pdev->dev.platform_data;
 
 		tmu->num_channels = hweight8(cfg->channels_mask);
+		tmu->model = id->driver_data;
 	} else {
 		dev_err(&tmu->pdev->dev, "missing platform data\n");
 		return -ENXIO;


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 10/19] clocksource: sh_tmu: Add DT support
@ 2014-06-16  8:34     ` Simon Horman
  0 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16  8:34 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Laurent,

thanks for your patch.

On Sat, Jun 14, 2014 at 06:23:32PM +0200, Laurent Pinchart wrote:
> Document DT bindings and parse them in the TMU driver.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

[snip]

> diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
> index ef8fb0b..2ece4ab 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,46 @@ 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->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) {
> +		struct sh_timer_config *cfg = pdev->dev.platform_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)) {

[snip]

I had a bit of trouble running this code and after some investigation
it seems to me that in the case of using DT id will be NULL and
thus things do not go well when id->driver_data is accessed.

The following incremental patch resolved the problem for me.

diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 2ece4ab..3f90927 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -523,6 +523,8 @@ static int sh_tmu_parse_dt(struct sh_tmu_device *tmu)
 		return -EINVAL;
 	}
 
+	tmu->model = SH_TMU;
+
 	return 0;
 }
 
@@ -533,7 +535,6 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 	int ret;
 
 	tmu->pdev = pdev;
-	tmu->model = id->driver_data;
 
 	raw_spin_lock_init(&tmu->lock);
 
@@ -545,6 +546,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
 		struct sh_timer_config *cfg = pdev->dev.platform_data;
 
 		tmu->num_channels = hweight8(cfg->channels_mask);
+		tmu->model = id->driver_data;
 	} else {
 		dev_err(&tmu->pdev->dev, "missing platform data\n");
 		return -ENXIO;

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
  2014-06-14 16:23   ` Laurent Pinchart
@ 2014-06-16  8:47     ` Simon Horman
  -1 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16  8:47 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Laurent,

thanks for your patch.

On Sat, Jun 14, 2014 at 06:23:36PM +0200, Laurent Pinchart wrote:
> Add the TMU0, TMU1 and TMU2 counters to the r8a7779 device tree and make
> them disabled by default.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  arch/arm/boot/dts/r8a7779.dtsi | 42 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
> index 94e2fc8..bf716ce 100644
> --- a/arch/arm/boot/dts/r8a7779.dtsi
> +++ b/arch/arm/boot/dts/r8a7779.dtsi
> @@ -266,6 +266,48 @@
>  		reg = <0xffc48000 0x38>;
>  	};
>  
> +	tmu0: timer@ffd80000 {
> +		compatible = "renesas,tmu";
> +		reg = <0xffd80000 0x30>;
> +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> +		clock-names = "fck";
> +
> +		#renesas,channels = <3>;
> +
> +		status = "disabled";
> +	};
> +
> +	tmu1: timer@ffd81000 {
> +		compatible = "renesas,tmu";
> +		reg = <0xffd81000 0x30>;
> +		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> +		clock-names = "fck";
> +
> +		#renesas,channels = <3>;
> +
> +		status = "disabled";
> +	};
> +
> +	tmu2: timer@ffd82000 {
> +		compatible = "renesas,tmu";
> +		reg = <0xffd82000 0x30>;
> +		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> +		clock-names = "fck";
> +
> +		#renesas,channels = <3>;
> +
> +		status = "disabled";
> +	};
> +
>  	sata: sata@fc600000 {
>  		compatible = "renesas,rcar-sata";
>  		reg = <0xfc600000 0x2000>;
> -- 
> 1.8.5.5

There are no interrupt-parents in in the nodes above nodes
although the documentation of the binding has one in the example.
Is it just an oversight in this patch?

I believe that the IRQ numbers are not correct.

In setup-r8a7779.c I see gic_iid(0x40). But above I see 40.
I think the correct value is 0x40 - 32 = 32. Likewise
for the other IRQs of tmu0. And looking at the documentaiton
this seems true for tmu1 and tmu2 too.

I have successfully booted a marzen board with the following incremental
patch to the DT nodes.

diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
index bf716ce..81714ce 100644
--- a/arch/arm/boot/dts/r8a7779.dtsi
+++ b/arch/arm/boot/dts/r8a7779.dtsi
@@ -269,9 +269,10 @@
 	tmu0: timer@ffd80000 {
 		compatible = "renesas,tmu";
 		reg = <0xffd80000 0x30>;
-		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-parent = <&gic>;
+		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";
 
@@ -283,9 +284,10 @@
 	tmu1: timer@ffd81000 {
 		compatible = "renesas,tmu";
 		reg = <0xffd81000 0x30>;
-		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 36 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 37 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
 		clock-names = "fck";
 
@@ -296,10 +298,11 @@
 
 	tmu2: timer@ffd82000 {
 		compatible = "renesas,tmu";
+		interrupt-parent = <&gic>;
 		reg = <0xffd82000 0x30>;
-		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
+		interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 39 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 40 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
 		clock-names = "fck";
 

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
@ 2014-06-16  8:47     ` Simon Horman
  0 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16  8:47 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Laurent,

thanks for your patch.

On Sat, Jun 14, 2014 at 06:23:36PM +0200, Laurent Pinchart wrote:
> Add the TMU0, TMU1 and TMU2 counters to the r8a7779 device tree and make
> them disabled by default.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  arch/arm/boot/dts/r8a7779.dtsi | 42 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
> index 94e2fc8..bf716ce 100644
> --- a/arch/arm/boot/dts/r8a7779.dtsi
> +++ b/arch/arm/boot/dts/r8a7779.dtsi
> @@ -266,6 +266,48 @@
>  		reg = <0xffc48000 0x38>;
>  	};
>  
> +	tmu0: timer at ffd80000 {
> +		compatible = "renesas,tmu";
> +		reg = <0xffd80000 0x30>;
> +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> +		clock-names = "fck";
> +
> +		#renesas,channels = <3>;
> +
> +		status = "disabled";
> +	};
> +
> +	tmu1: timer at ffd81000 {
> +		compatible = "renesas,tmu";
> +		reg = <0xffd81000 0x30>;
> +		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> +		clock-names = "fck";
> +
> +		#renesas,channels = <3>;
> +
> +		status = "disabled";
> +	};
> +
> +	tmu2: timer at ffd82000 {
> +		compatible = "renesas,tmu";
> +		reg = <0xffd82000 0x30>;
> +		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> +		clock-names = "fck";
> +
> +		#renesas,channels = <3>;
> +
> +		status = "disabled";
> +	};
> +
>  	sata: sata at fc600000 {
>  		compatible = "renesas,rcar-sata";
>  		reg = <0xfc600000 0x2000>;
> -- 
> 1.8.5.5

There are no interrupt-parents in in the nodes above nodes
although the documentation of the binding has one in the example.
Is it just an oversight in this patch?

I believe that the IRQ numbers are not correct.

In setup-r8a7779.c I see gic_iid(0x40). But above I see 40.
I think the correct value is 0x40 - 32 = 32. Likewise
for the other IRQs of tmu0. And looking at the documentaiton
this seems true for tmu1 and tmu2 too.

I have successfully booted a marzen board with the following incremental
patch to the DT nodes.

diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
index bf716ce..81714ce 100644
--- a/arch/arm/boot/dts/r8a7779.dtsi
+++ b/arch/arm/boot/dts/r8a7779.dtsi
@@ -269,9 +269,10 @@
 	tmu0: timer at ffd80000 {
 		compatible = "renesas,tmu";
 		reg = <0xffd80000 0x30>;
-		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-parent = <&gic>;
+		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";
 
@@ -283,9 +284,10 @@
 	tmu1: timer at ffd81000 {
 		compatible = "renesas,tmu";
 		reg = <0xffd81000 0x30>;
-		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 36 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 37 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
 		clock-names = "fck";
 
@@ -296,10 +298,11 @@
 
 	tmu2: timer at ffd82000 {
 		compatible = "renesas,tmu";
+		interrupt-parent = <&gic>;
 		reg = <0xffd82000 0x30>;
-		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
-			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
+		interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 39 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 40 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
 		clock-names = "fck";
 

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 10/19] clocksource: sh_tmu: Add DT support
  2014-06-14 16:23   ` Laurent Pinchart
@ 2014-06-16  8:48     ` Simon Horman
  -1 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16  8:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Jun 14, 2014 at 06:23:32PM +0200, Laurent Pinchart wrote:
> Document DT bindings and parse them in the TMU driver.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  .../devicetree/bindings/timer/renesas,tmu.txt      | 40 +++++++++++++++++++
>  drivers/clocksource/sh_tmu.c                       | 45 ++++++++++++++++++----
>  2 files changed, 77 insertions(+), 8 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..2392e89
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/renesas,tmu.txt
> @@ -0,0 +1,40 @@
> +* 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>;
> +		interrupt-parent = <&gic>;
> +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> +		clock-names = "fck";
> +
> +		#renesas,channels = <3>;
> +	};

As per my feedback for "[PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU
devices to DT" I believe the IRQ values should be 32, 33 and 34, not 40,
41, 42. I realise this is just an example but I feel that I should mention
it.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 10/19] clocksource: sh_tmu: Add DT support
@ 2014-06-16  8:48     ` Simon Horman
  0 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16  8:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Jun 14, 2014 at 06:23:32PM +0200, Laurent Pinchart wrote:
> Document DT bindings and parse them in the TMU driver.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  .../devicetree/bindings/timer/renesas,tmu.txt      | 40 +++++++++++++++++++
>  drivers/clocksource/sh_tmu.c                       | 45 ++++++++++++++++++----
>  2 files changed, 77 insertions(+), 8 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..2392e89
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/renesas,tmu.txt
> @@ -0,0 +1,40 @@
> +* 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 at ffd80000 {
> +		compatible = "renesas,tmu";
> +		reg = <0xffd80000 0x30>;
> +		interrupt-parent = <&gic>;
> +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> +		clock-names = "fck";
> +
> +		#renesas,channels = <3>;
> +	};

As per my feedback for "[PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU
devices to DT" I believe the IRQ values should be 32, 33 and 34, not 40,
41, 42. I realise this is just an example but I feel that I should mention
it.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 00/19] Renesas CMT, MTU2 and TMU timers DT support
  2014-06-14 16:23 ` Laurent Pinchart
@ 2014-06-16  9:00   ` Simon Horman
  -1 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16  9:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Jun 14, 2014 at 06:23:22PM +0200, Laurent Pinchart wrote:
> Hello,
> 
> This patch set adds DT bindings to the Renesas CMT, MTU2 and TMU timers.
> Patches 02/19 to 13/19, 16/19 and 17/19 have already been posted in the
> previous version of this series. Patches 14/19, 15/19, 18/19 and 19/19 are
> new.
> 
> Compared to v2 I've rebased the patches on top of Simon's latest devel branch.
> 
> Compared to v1 I've dropped the channel subnodes from the CMT DT bindings and
> just use a channels mask, as I don't need to specify per-channel properties.
> I'm slightly uncertain about this change though, as I can't easily predict
> whether per-channel properties would be needed later for new hardware. It
> won't be difficult to reintroduce channel subnodes then, so I'd rather not
> clutter the DT bindings with channel subnodes now. Please feel free to
> disagree.
> 
> The first 11 patches should go through the timers tree while the last 8
> patches should go through the Renesas SoC tree. Patches 12/19 to 15/19 have
> no build time or run time dependency on the drivers changes. Patches 16/19 to
> 19/19 may have a run time dependency on the drivers changes depending on the
> kernel configuration. Patches 16/19 and 17/19, for instance, require the
> driver changes only when architected timer support isn't enabled in the
> kernel.
> 
> Laurent Pinchart (19):
> o clocksource: sh_tmu: Fix channel IRQ retrieval in legacy case
> o clocksource: sh_cmt: Drop support for legacy platform data
> o clocksource: sh_cmt: Replace global spinlock with a per-device
>     spinlock
> o clocksource: sh_tmu: Drop support for legacy platform data
> o clocksource: sh_tmu: Replace global spinlock with a per-device
>     spinlock
>   clocksource: sh_mtu2: Drop support for legacy platform data
>   clocksource: sh_mtu2: Replace global spinlock with a per-device
>     spinlock
> o clocksource: shmobile: Remove unused sh_timer_config members
> o clocksource: sh_cmt: Add DT support
>   clocksource: sh_tmu: Add DT support
>   clocksource: sh_mtu2: Add DT support
> o ARM: shmobile: r8a7790: Add CMT devices to DT
> o ARM: shmobile: r8a7791: Add CMT devices to DT
>   ARM: shmobile: r8a7779: Add TMU devices to DT
>   ARM: shmobile: r7s72100: Add MTU2 device to DT
> o ARM: shmobile: lager-reference: Enable CMT0 in device tree
> o ARM: shmobile: koelsch-reference: Enable CMT0 in device tree
>   ARM: shmobile: marzen-reference: Enable TMU0 in device tree
>   ARM: shmobile: genmai-reference: Enable MTU2 in device tree

For the patches marked with a 'o':

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

>  .../devicetree/bindings/timer/renesas,cmt.txt      |  49 +++++
>  .../devicetree/bindings/timer/renesas,mtu2.txt     |  40 ++++
>  .../devicetree/bindings/timer/renesas,tmu.txt      |  40 ++++
>  arch/arm/boot/dts/r7s72100-genmai.dts              |   4 +
>  arch/arm/boot/dts/r7s72100.dtsi                    |  10 +
>  arch/arm/boot/dts/r8a7779-marzen.dts               |   4 +
>  arch/arm/boot/dts/r8a7779.dtsi                     |  42 ++++
>  arch/arm/boot/dts/r8a7790-lager.dts                |   4 +
>  arch/arm/boot/dts/r8a7790.dtsi                     |  34 +++
>  arch/arm/boot/dts/r8a7791-koelsch.dts              |   4 +
>  arch/arm/boot/dts/r8a7791.dtsi                     |  34 +++
>  arch/arm/mach-shmobile/board-genmai-reference.c    |  16 --
>  arch/arm/mach-shmobile/board-genmai.c              |  14 +-
>  arch/arm/mach-shmobile/board-koelsch-reference.c   |   2 -
>  arch/arm/mach-shmobile/board-lager-reference.c     |   2 -
>  arch/arm/mach-shmobile/board-marzen-reference.c    |  10 -
>  arch/arm/mach-shmobile/include/mach/r7s72100.h     |   1 -
>  arch/arm/mach-shmobile/include/mach/r8a7779.h      |   1 -
>  arch/arm/mach-shmobile/include/mach/r8a7790.h      |   1 -
>  arch/arm/mach-shmobile/include/mach/r8a7791.h      |   1 -
>  arch/arm/mach-shmobile/setup-r7s72100.c            |  21 --
>  arch/arm/mach-shmobile/setup-r8a7779.c             |  17 +-
>  arch/arm/mach-shmobile/setup-r8a7790.c             |   7 +-
>  arch/arm/mach-shmobile/setup-r8a7791.c             |   7 +-
>  drivers/clocksource/sh_cmt.c                       | 233 ++++++++-------------
>  drivers/clocksource/sh_mtu2.c                      | 146 ++++---------
>  drivers/clocksource/sh_tmu.c                       | 125 +++++------
>  include/linux/sh_timer.h                           |   5 -
>  28 files changed, 467 insertions(+), 407 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/timer/renesas,cmt.txt
>  create mode 100644 Documentation/devicetree/bindings/timer/renesas,mtu2.txt
>  create mode 100644 Documentation/devicetree/bindings/timer/renesas,tmu.txt
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> --
> 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
> 

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 00/19] Renesas CMT, MTU2 and TMU timers DT support
@ 2014-06-16  9:00   ` Simon Horman
  0 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16  9:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Jun 14, 2014 at 06:23:22PM +0200, Laurent Pinchart wrote:
> Hello,
> 
> This patch set adds DT bindings to the Renesas CMT, MTU2 and TMU timers.
> Patches 02/19 to 13/19, 16/19 and 17/19 have already been posted in the
> previous version of this series. Patches 14/19, 15/19, 18/19 and 19/19 are
> new.
> 
> Compared to v2 I've rebased the patches on top of Simon's latest devel branch.
> 
> Compared to v1 I've dropped the channel subnodes from the CMT DT bindings and
> just use a channels mask, as I don't need to specify per-channel properties.
> I'm slightly uncertain about this change though, as I can't easily predict
> whether per-channel properties would be needed later for new hardware. It
> won't be difficult to reintroduce channel subnodes then, so I'd rather not
> clutter the DT bindings with channel subnodes now. Please feel free to
> disagree.
> 
> The first 11 patches should go through the timers tree while the last 8
> patches should go through the Renesas SoC tree. Patches 12/19 to 15/19 have
> no build time or run time dependency on the drivers changes. Patches 16/19 to
> 19/19 may have a run time dependency on the drivers changes depending on the
> kernel configuration. Patches 16/19 and 17/19, for instance, require the
> driver changes only when architected timer support isn't enabled in the
> kernel.
> 
> Laurent Pinchart (19):
> o clocksource: sh_tmu: Fix channel IRQ retrieval in legacy case
> o clocksource: sh_cmt: Drop support for legacy platform data
> o clocksource: sh_cmt: Replace global spinlock with a per-device
>     spinlock
> o clocksource: sh_tmu: Drop support for legacy platform data
> o clocksource: sh_tmu: Replace global spinlock with a per-device
>     spinlock
>   clocksource: sh_mtu2: Drop support for legacy platform data
>   clocksource: sh_mtu2: Replace global spinlock with a per-device
>     spinlock
> o clocksource: shmobile: Remove unused sh_timer_config members
> o clocksource: sh_cmt: Add DT support
>   clocksource: sh_tmu: Add DT support
>   clocksource: sh_mtu2: Add DT support
> o ARM: shmobile: r8a7790: Add CMT devices to DT
> o ARM: shmobile: r8a7791: Add CMT devices to DT
>   ARM: shmobile: r8a7779: Add TMU devices to DT
>   ARM: shmobile: r7s72100: Add MTU2 device to DT
> o ARM: shmobile: lager-reference: Enable CMT0 in device tree
> o ARM: shmobile: koelsch-reference: Enable CMT0 in device tree
>   ARM: shmobile: marzen-reference: Enable TMU0 in device tree
>   ARM: shmobile: genmai-reference: Enable MTU2 in device tree

For the patches marked with a 'o':

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

>  .../devicetree/bindings/timer/renesas,cmt.txt      |  49 +++++
>  .../devicetree/bindings/timer/renesas,mtu2.txt     |  40 ++++
>  .../devicetree/bindings/timer/renesas,tmu.txt      |  40 ++++
>  arch/arm/boot/dts/r7s72100-genmai.dts              |   4 +
>  arch/arm/boot/dts/r7s72100.dtsi                    |  10 +
>  arch/arm/boot/dts/r8a7779-marzen.dts               |   4 +
>  arch/arm/boot/dts/r8a7779.dtsi                     |  42 ++++
>  arch/arm/boot/dts/r8a7790-lager.dts                |   4 +
>  arch/arm/boot/dts/r8a7790.dtsi                     |  34 +++
>  arch/arm/boot/dts/r8a7791-koelsch.dts              |   4 +
>  arch/arm/boot/dts/r8a7791.dtsi                     |  34 +++
>  arch/arm/mach-shmobile/board-genmai-reference.c    |  16 --
>  arch/arm/mach-shmobile/board-genmai.c              |  14 +-
>  arch/arm/mach-shmobile/board-koelsch-reference.c   |   2 -
>  arch/arm/mach-shmobile/board-lager-reference.c     |   2 -
>  arch/arm/mach-shmobile/board-marzen-reference.c    |  10 -
>  arch/arm/mach-shmobile/include/mach/r7s72100.h     |   1 -
>  arch/arm/mach-shmobile/include/mach/r8a7779.h      |   1 -
>  arch/arm/mach-shmobile/include/mach/r8a7790.h      |   1 -
>  arch/arm/mach-shmobile/include/mach/r8a7791.h      |   1 -
>  arch/arm/mach-shmobile/setup-r7s72100.c            |  21 --
>  arch/arm/mach-shmobile/setup-r8a7779.c             |  17 +-
>  arch/arm/mach-shmobile/setup-r8a7790.c             |   7 +-
>  arch/arm/mach-shmobile/setup-r8a7791.c             |   7 +-
>  drivers/clocksource/sh_cmt.c                       | 233 ++++++++-------------
>  drivers/clocksource/sh_mtu2.c                      | 146 ++++---------
>  drivers/clocksource/sh_tmu.c                       | 125 +++++------
>  include/linux/sh_timer.h                           |   5 -
>  28 files changed, 467 insertions(+), 407 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/timer/renesas,cmt.txt
>  create mode 100644 Documentation/devicetree/bindings/timer/renesas,mtu2.txt
>  create mode 100644 Documentation/devicetree/bindings/timer/renesas,tmu.txt
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
  2014-06-16  8:47     ` Simon Horman
  (?)
@ 2014-06-16 14:22       ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:22 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

On Monday 16 June 2014 17:47:07 Simon Horman wrote:
> On Sat, Jun 14, 2014 at 06:23:36PM +0200, Laurent Pinchart wrote:
> > Add the TMU0, TMU1 and TMU2 counters to the r8a7779 device tree and make
> > them disabled by default.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >  arch/arm/boot/dts/r8a7779.dtsi | 42 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 42 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/r8a7779.dtsi
> > b/arch/arm/boot/dts/r8a7779.dtsi index 94e2fc8..bf716ce 100644
> > --- a/arch/arm/boot/dts/r8a7779.dtsi
> > +++ b/arch/arm/boot/dts/r8a7779.dtsi
> > @@ -266,6 +266,48 @@
> >  		reg = <0xffc48000 0x38>;
> >  	};
> > 
> > +	tmu0: timer@ffd80000 {
> > +		compatible = "renesas,tmu";
> > +		reg = <0xffd80000 0x30>;
> > +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> > +	tmu1: timer@ffd81000 {
> > +		compatible = "renesas,tmu";
> > +		reg = <0xffd81000 0x30>;
> > +		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> > +	tmu2: timer@ffd82000 {
> > +		compatible = "renesas,tmu";
> > +		reg = <0xffd82000 0x30>;
> > +		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> >  	sata: sata@fc600000 {
> >  		compatible = "renesas,rcar-sata";
> >  		reg = <0xfc600000 0x2000>;
> 
> There are no interrupt-parents in in the nodes above nodes
> although the documentation of the binding has one in the example.
> Is it just an oversight in this patch?

Not really.

The interrupt-parent property is required but can be inherited. Furthermore, 
the interrupts-extended property can be used to replace the interrupts and 
interrupt-parent properties. This should all be documented in the DT bindings, 
but not by duplicating the full explanation in dozens of different flavours in 
all bindings. We need standard wordings for common properties such as 
interrupts, clocks or reg.

> I believe that the IRQ numbers are not correct.
> 
> In setup-r8a7779.c I see gic_iid(0x40). But above I see 40.
> I think the correct value is 0x40 - 32 = 32. Likewise
> for the other IRQs of tmu0. And looking at the documentaiton
> this seems true for tmu1 and tmu2 too.
>
> I have successfully booted a marzen board with the following incremental
> patch to the DT nodes.

You're right, sorry about that. I'll fix the interrupt numbers and resubmit. 
The interrupt-parent is specified at the top level so there's no need to add 
it to the TMU nodes.

> diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
> index bf716ce..81714ce 100644
> --- a/arch/arm/boot/dts/r8a7779.dtsi
> +++ b/arch/arm/boot/dts/r8a7779.dtsi
> @@ -269,9 +269,10 @@
>  	tmu0: timer@ffd80000 {
>  		compatible = "renesas,tmu";
>  		reg = <0xffd80000 0x30>;
> -		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> +		interrupt-parent = <&gic>;
> +		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";
> 
> @@ -283,9 +284,10 @@
>  	tmu1: timer@ffd81000 {
>  		compatible = "renesas,tmu";
>  		reg = <0xffd81000 0x30>;
> -		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> +		interrupt-parent = <&gic>;
> +		interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 36 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 37 IRQ_TYPE_LEVEL_HIGH>;

If I'm not mistaken the interrupts should be 36, 37 and 38.

>  		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
>  		clock-names = "fck";
> 
> @@ -296,10 +298,11 @@
> 
>  	tmu2: timer@ffd82000 {
>  		compatible = "renesas,tmu";
> +		interrupt-parent = <&gic>;
>  		reg = <0xffd82000 0x30>;
> -		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> +		interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 39 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 40 IRQ_TYPE_LEVEL_HIGH>;

And 40, 41 and 42 here.

>  		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
>  		clock-names = "fck";

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
@ 2014-06-16 14:22       ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:22 UTC (permalink / raw)
  To: Simon Horman
  Cc: Laurent Pinchart, linux-sh, linux-arm-kernel, Daniel Lezcano,
	Thomas Gleixner, devicetree

Hi Simon,

On Monday 16 June 2014 17:47:07 Simon Horman wrote:
> On Sat, Jun 14, 2014 at 06:23:36PM +0200, Laurent Pinchart wrote:
> > Add the TMU0, TMU1 and TMU2 counters to the r8a7779 device tree and make
> > them disabled by default.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >  arch/arm/boot/dts/r8a7779.dtsi | 42 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 42 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/r8a7779.dtsi
> > b/arch/arm/boot/dts/r8a7779.dtsi index 94e2fc8..bf716ce 100644
> > --- a/arch/arm/boot/dts/r8a7779.dtsi
> > +++ b/arch/arm/boot/dts/r8a7779.dtsi
> > @@ -266,6 +266,48 @@
> >  		reg = <0xffc48000 0x38>;
> >  	};
> > 
> > +	tmu0: timer@ffd80000 {
> > +		compatible = "renesas,tmu";
> > +		reg = <0xffd80000 0x30>;
> > +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> > +	tmu1: timer@ffd81000 {
> > +		compatible = "renesas,tmu";
> > +		reg = <0xffd81000 0x30>;
> > +		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> > +	tmu2: timer@ffd82000 {
> > +		compatible = "renesas,tmu";
> > +		reg = <0xffd82000 0x30>;
> > +		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> >  	sata: sata@fc600000 {
> >  		compatible = "renesas,rcar-sata";
> >  		reg = <0xfc600000 0x2000>;
> 
> There are no interrupt-parents in in the nodes above nodes
> although the documentation of the binding has one in the example.
> Is it just an oversight in this patch?

Not really.

The interrupt-parent property is required but can be inherited. Furthermore, 
the interrupts-extended property can be used to replace the interrupts and 
interrupt-parent properties. This should all be documented in the DT bindings, 
but not by duplicating the full explanation in dozens of different flavours in 
all bindings. We need standard wordings for common properties such as 
interrupts, clocks or reg.

> I believe that the IRQ numbers are not correct.
> 
> In setup-r8a7779.c I see gic_iid(0x40). But above I see 40.
> I think the correct value is 0x40 - 32 = 32. Likewise
> for the other IRQs of tmu0. And looking at the documentaiton
> this seems true for tmu1 and tmu2 too.
>
> I have successfully booted a marzen board with the following incremental
> patch to the DT nodes.

You're right, sorry about that. I'll fix the interrupt numbers and resubmit. 
The interrupt-parent is specified at the top level so there's no need to add 
it to the TMU nodes.

> diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
> index bf716ce..81714ce 100644
> --- a/arch/arm/boot/dts/r8a7779.dtsi
> +++ b/arch/arm/boot/dts/r8a7779.dtsi
> @@ -269,9 +269,10 @@
>  	tmu0: timer@ffd80000 {
>  		compatible = "renesas,tmu";
>  		reg = <0xffd80000 0x30>;
> -		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> +		interrupt-parent = <&gic>;
> +		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";
> 
> @@ -283,9 +284,10 @@
>  	tmu1: timer@ffd81000 {
>  		compatible = "renesas,tmu";
>  		reg = <0xffd81000 0x30>;
> -		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> +		interrupt-parent = <&gic>;
> +		interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 36 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 37 IRQ_TYPE_LEVEL_HIGH>;

If I'm not mistaken the interrupts should be 36, 37 and 38.

>  		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
>  		clock-names = "fck";
> 
> @@ -296,10 +298,11 @@
> 
>  	tmu2: timer@ffd82000 {
>  		compatible = "renesas,tmu";
> +		interrupt-parent = <&gic>;
>  		reg = <0xffd82000 0x30>;
> -		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> +		interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 39 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 40 IRQ_TYPE_LEVEL_HIGH>;

And 40, 41 and 42 here.

>  		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
>  		clock-names = "fck";

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
@ 2014-06-16 14:22       ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:22 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

On Monday 16 June 2014 17:47:07 Simon Horman wrote:
> On Sat, Jun 14, 2014 at 06:23:36PM +0200, Laurent Pinchart wrote:
> > Add the TMU0, TMU1 and TMU2 counters to the r8a7779 device tree and make
> > them disabled by default.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >  arch/arm/boot/dts/r8a7779.dtsi | 42 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 42 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/r8a7779.dtsi
> > b/arch/arm/boot/dts/r8a7779.dtsi index 94e2fc8..bf716ce 100644
> > --- a/arch/arm/boot/dts/r8a7779.dtsi
> > +++ b/arch/arm/boot/dts/r8a7779.dtsi
> > @@ -266,6 +266,48 @@
> >  		reg = <0xffc48000 0x38>;
> >  	};
> > 
> > +	tmu0: timer at ffd80000 {
> > +		compatible = "renesas,tmu";
> > +		reg = <0xffd80000 0x30>;
> > +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> > +	tmu1: timer at ffd81000 {
> > +		compatible = "renesas,tmu";
> > +		reg = <0xffd81000 0x30>;
> > +		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> > +	tmu2: timer at ffd82000 {
> > +		compatible = "renesas,tmu";
> > +		reg = <0xffd82000 0x30>;
> > +		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> >  	sata: sata at fc600000 {
> >  		compatible = "renesas,rcar-sata";
> >  		reg = <0xfc600000 0x2000>;
> 
> There are no interrupt-parents in in the nodes above nodes
> although the documentation of the binding has one in the example.
> Is it just an oversight in this patch?

Not really.

The interrupt-parent property is required but can be inherited. Furthermore, 
the interrupts-extended property can be used to replace the interrupts and 
interrupt-parent properties. This should all be documented in the DT bindings, 
but not by duplicating the full explanation in dozens of different flavours in 
all bindings. We need standard wordings for common properties such as 
interrupts, clocks or reg.

> I believe that the IRQ numbers are not correct.
> 
> In setup-r8a7779.c I see gic_iid(0x40). But above I see 40.
> I think the correct value is 0x40 - 32 = 32. Likewise
> for the other IRQs of tmu0. And looking at the documentaiton
> this seems true for tmu1 and tmu2 too.
>
> I have successfully booted a marzen board with the following incremental
> patch to the DT nodes.

You're right, sorry about that. I'll fix the interrupt numbers and resubmit. 
The interrupt-parent is specified at the top level so there's no need to add 
it to the TMU nodes.

> diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
> index bf716ce..81714ce 100644
> --- a/arch/arm/boot/dts/r8a7779.dtsi
> +++ b/arch/arm/boot/dts/r8a7779.dtsi
> @@ -269,9 +269,10 @@
>  	tmu0: timer at ffd80000 {
>  		compatible = "renesas,tmu";
>  		reg = <0xffd80000 0x30>;
> -		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> +		interrupt-parent = <&gic>;
> +		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";
> 
> @@ -283,9 +284,10 @@
>  	tmu1: timer at ffd81000 {
>  		compatible = "renesas,tmu";
>  		reg = <0xffd81000 0x30>;
> -		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> +		interrupt-parent = <&gic>;
> +		interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 36 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 37 IRQ_TYPE_LEVEL_HIGH>;

If I'm not mistaken the interrupts should be 36, 37 and 38.

>  		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
>  		clock-names = "fck";
> 
> @@ -296,10 +298,11 @@
> 
>  	tmu2: timer at ffd82000 {
>  		compatible = "renesas,tmu";
> +		interrupt-parent = <&gic>;
>  		reg = <0xffd82000 0x30>;
> -		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> -			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> +		interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 39 IRQ_TYPE_LEVEL_HIGH>,
> +			     <0 40 IRQ_TYPE_LEVEL_HIGH>;

And 40, 41 and 42 here.

>  		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
>  		clock-names = "fck";

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 10/19] clocksource: sh_tmu: Add DT support
  2014-06-16  8:48     ` Simon Horman
@ 2014-06-16 14:24       ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:24 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

On Monday 16 June 2014 17:48:32 Simon Horman wrote:
> On Sat, Jun 14, 2014 at 06:23:32PM +0200, Laurent Pinchart wrote:
> > Document DT bindings and parse them in the TMU driver.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >  .../devicetree/bindings/timer/renesas,tmu.txt      | 40 +++++++++++++++++
> >  drivers/clocksource/sh_tmu.c                       | 45 +++++++++++++----
> >  2 files changed, 77 insertions(+), 8 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..2392e89
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/timer/renesas,tmu.txt
> > @@ -0,0 +1,40 @@
> > +* 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>;
> > +		interrupt-parent = <&gic>;
> > +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +	};
> 
> As per my feedback for "[PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU
> devices to DT" I believe the IRQ values should be 32, 33 and 34, not 40,
> 41, 42. I realise this is just an example but I feel that I should mention
> it.

Sure, I'll fix that, and remove the interrupt-parent property.

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 10/19] clocksource: sh_tmu: Add DT support
@ 2014-06-16 14:24       ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:24 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

On Monday 16 June 2014 17:48:32 Simon Horman wrote:
> On Sat, Jun 14, 2014 at 06:23:32PM +0200, Laurent Pinchart wrote:
> > Document DT bindings and parse them in the TMU driver.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >  .../devicetree/bindings/timer/renesas,tmu.txt      | 40 +++++++++++++++++
> >  drivers/clocksource/sh_tmu.c                       | 45 +++++++++++++----
> >  2 files changed, 77 insertions(+), 8 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..2392e89
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/timer/renesas,tmu.txt
> > @@ -0,0 +1,40 @@
> > +* 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 at ffd80000 {
> > +		compatible = "renesas,tmu";
> > +		reg = <0xffd80000 0x30>;
> > +		interrupt-parent = <&gic>;
> > +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> > +		clock-names = "fck";
> > +
> > +		#renesas,channels = <3>;
> > +	};
> 
> As per my feedback for "[PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU
> devices to DT" I believe the IRQ values should be 32, 33 and 34, not 40,
> 41, 42. I realise this is just an example but I feel that I should mention
> it.

Sure, I'll fix that, and remove the interrupt-parent property.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 10/19] clocksource: sh_tmu: Add DT support
  2014-06-16  8:34     ` Simon Horman
@ 2014-06-16 14:32       ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

On Monday 16 June 2014 17:34:23 Simon Horman wrote:
> On Sat, Jun 14, 2014 at 06:23:32PM +0200, Laurent Pinchart wrote:
> > Document DT bindings and parse them in the TMU driver.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> 
> [snip]
> 
> > diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
> > index ef8fb0b..2ece4ab 100644
> > --- a/drivers/clocksource/sh_tmu.c
> > +++ b/drivers/clocksource/sh_tmu.c

[snip]

> > @@ -509,23 +510,46 @@ 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->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) {
> > +		struct sh_timer_config *cfg = pdev->dev.platform_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)) {
> 
> [snip]
> 
> I had a bit of trouble running this code and after some investigation
> it seems to me that in the case of using DT id will be NULL and
> thus things do not go well when id->driver_data is accessed.

Indeed. I wonder how I've missed that :-/ Anyway, I'll fix it and resubmit.

> The following incremental patch resolved the problem for me.
> 
> diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
> index 2ece4ab..3f90927 100644
> --- a/drivers/clocksource/sh_tmu.c
> +++ b/drivers/clocksource/sh_tmu.c
> @@ -523,6 +523,8 @@ static int sh_tmu_parse_dt(struct sh_tmu_device *tmu)
>  		return -EINVAL;
>  	}
> 
> +	tmu->model = SH_TMU;
> +
>  	return 0;
>  }
> 
> @@ -533,7 +535,6 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu,
> struct platform_device *pdev) int ret;
> 
>  	tmu->pdev = pdev;
> -	tmu->model = id->driver_data;
> 
>  	raw_spin_lock_init(&tmu->lock);
> 
> @@ -545,6 +546,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu,
> struct platform_device *pdev) struct sh_timer_config *cfg > pdev->dev.platform_data;
> 
>  		tmu->num_channels = hweight8(cfg->channels_mask);
> +		tmu->model = id->driver_data;
>  	} else {
>  		dev_err(&tmu->pdev->dev, "missing platform data\n");
>  		return -ENXIO;

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 10/19] clocksource: sh_tmu: Add DT support
@ 2014-06-16 14:32       ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

On Monday 16 June 2014 17:34:23 Simon Horman wrote:
> On Sat, Jun 14, 2014 at 06:23:32PM +0200, Laurent Pinchart wrote:
> > Document DT bindings and parse them in the TMU driver.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> 
> [snip]
> 
> > diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
> > index ef8fb0b..2ece4ab 100644
> > --- a/drivers/clocksource/sh_tmu.c
> > +++ b/drivers/clocksource/sh_tmu.c

[snip]

> > @@ -509,23 +510,46 @@ 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->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) {
> > +		struct sh_timer_config *cfg = pdev->dev.platform_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)) {
> 
> [snip]
> 
> I had a bit of trouble running this code and after some investigation
> it seems to me that in the case of using DT id will be NULL and
> thus things do not go well when id->driver_data is accessed.

Indeed. I wonder how I've missed that :-/ Anyway, I'll fix it and resubmit.

> The following incremental patch resolved the problem for me.
> 
> diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
> index 2ece4ab..3f90927 100644
> --- a/drivers/clocksource/sh_tmu.c
> +++ b/drivers/clocksource/sh_tmu.c
> @@ -523,6 +523,8 @@ static int sh_tmu_parse_dt(struct sh_tmu_device *tmu)
>  		return -EINVAL;
>  	}
> 
> +	tmu->model = SH_TMU;
> +
>  	return 0;
>  }
> 
> @@ -533,7 +535,6 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu,
> struct platform_device *pdev) int ret;
> 
>  	tmu->pdev = pdev;
> -	tmu->model = id->driver_data;
> 
>  	raw_spin_lock_init(&tmu->lock);
> 
> @@ -545,6 +546,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu,
> struct platform_device *pdev) struct sh_timer_config *cfg =
> pdev->dev.platform_data;
> 
>  		tmu->num_channels = hweight8(cfg->channels_mask);
> +		tmu->model = id->driver_data;
>  	} else {
>  		dev_err(&tmu->pdev->dev, "missing platform data\n");
>  		return -ENXIO;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 12/19] ARM: shmobile: r8a7790: Add CMT devices to DT
  2014-06-14 16:54     ` Sergei Shtylyov
@ 2014-06-16 14:38       ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:38 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sergei,

On Saturday 14 June 2014 20:54:05 Sergei Shtylyov wrote:
> On 06/14/2014 08:23 PM, Laurent Pinchart wrote:
> > Add the CMT0 and CMT1 counters to the r8a7790 device tree and make them
> > disabled by default.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >   arch/arm/boot/dts/r8a7790.dtsi | 34 ++++++++++++++++++++++++++++++++++
> >   1 file changed, 34 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/r8a7790.dtsi
> > b/arch/arm/boot/dts/r8a7790.dtsi index 29907c9..cc32ac5 100644
> > --- a/arch/arm/boot/dts/r8a7790.dtsi
> > +++ b/arch/arm/boot/dts/r8a7790.dtsi
> > @@ -206,6 +206,40 @@
> >   			     <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
> >   	};
> > 
> > +	cmt0: timer@ffca0000 {
> > +		compatible = "renesas,cmt-48-gen2";
> > +		reg = <0 0xffca0000 0 0x1004>;
> > +		interrupt-parent = <&gic>;
> 
> This prop is inherited from the root node, so unneeded here.

Thank you, I'll fix that. Same for patch 13/19.

> > +		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
> > +		clock-names = "fck";
> > +
> > +		renesas,channels-mask = <0x60>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> > +	cmt1: timer@e6130000 {
> > +		compatible = "renesas,cmt-48-gen2";
> > +		reg = <0 0xe6130000 0 0x1004>;
> > +		interrupt-parent = <&gic>;
> 
> Likewise.

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 12/19] ARM: shmobile: r8a7790: Add CMT devices to DT
@ 2014-06-16 14:38       ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:38 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sergei,

On Saturday 14 June 2014 20:54:05 Sergei Shtylyov wrote:
> On 06/14/2014 08:23 PM, Laurent Pinchart wrote:
> > Add the CMT0 and CMT1 counters to the r8a7790 device tree and make them
> > disabled by default.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >   arch/arm/boot/dts/r8a7790.dtsi | 34 ++++++++++++++++++++++++++++++++++
> >   1 file changed, 34 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/r8a7790.dtsi
> > b/arch/arm/boot/dts/r8a7790.dtsi index 29907c9..cc32ac5 100644
> > --- a/arch/arm/boot/dts/r8a7790.dtsi
> > +++ b/arch/arm/boot/dts/r8a7790.dtsi
> > @@ -206,6 +206,40 @@
> >   			     <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
> >   	};
> > 
> > +	cmt0: timer at ffca0000 {
> > +		compatible = "renesas,cmt-48-gen2";
> > +		reg = <0 0xffca0000 0 0x1004>;
> > +		interrupt-parent = <&gic>;
> 
> This prop is inherited from the root node, so unneeded here.

Thank you, I'll fix that. Same for patch 13/19.

> > +		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
> > +		clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
> > +		clock-names = "fck";
> > +
> > +		renesas,channels-mask = <0x60>;
> > +
> > +		status = "disabled";
> > +	};
> > +
> > +	cmt1: timer at e6130000 {
> > +		compatible = "renesas,cmt-48-gen2";
> > +		reg = <0 0xe6130000 0 0x1004>;
> > +		interrupt-parent = <&gic>;
> 
> Likewise.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 11/19] clocksource: sh_mtu2: Add DT support
  2014-06-14 17:00     ` Sergei Shtylyov
@ 2014-06-16 14:40       ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sergei,

On Saturday 14 June 2014 21:00:20 Sergei Shtylyov wrote:
> On 06/14/2014 08:23 PM, Laurent Pinchart wrote:
> > Document DT bindings and parse them in the MTU2 driver.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > Tested-by: Wolfram Sang <wsa@sang-engineering.com>
> > ---
> > 
> >  .../devicetree/bindings/timer/renesas,mtu2.txt     | 40 +++++++++++++++++
> >  drivers/clocksource/sh_mtu2.c                      |  8 +++++
> >   2 files changed, 48 insertions(+)
> >   create mode 100644
> >   Documentation/devicetree/bindings/timer/renesas,mtu2.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
> > b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt new file mode
> > 100644
> > index 0000000..c5dd032
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
> > @@ -0,0 +1,40 @@
> > +* Renesas R-Car Multi-Function Timer Pulse Unit 2 (MTU2)
> > +
> > +The MTU2 is a multi-purpose, multi-channel timer/counter with
> > configurable
> > +clock inputs and programmable compare match.
> > +
> > +Channels share hardware resources but their counter and compare match
> > value
> > +are independent. The MTU2 hardware supports five channels indexed from 0
> > to 4.
> > +
> > +Required Properties:
> > +
> > +  - compatible: must contain "renesas,mtu2"
> > +
> > +  - reg: base address and length of the registers block for the timer
> > module.
> > +
> > +  - interrupt-parent, interrupts: interrupt specifiers for the timer, one
> > for
> > +    each entry in interrupt-names.
> 
> The "interrupt-parent" has never been a required property, it can and should
> be inherited from an upper level node.

Only when it makes sense (which is the case here). We need a standard wording 
to describe the interrupt-related properties. In the meantime I'll drop 
interrupt-parent.

> [...]
> 
> > diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
> > index ebdf9d1..79387af 100644
> > --- a/drivers/clocksource/sh_mtu2.c
> > +++ b/drivers/clocksource/sh_mtu2.c
> 
> [...]
> 
> > @@ -502,11 +503,18 @@ static const struct platform_device_id
> > sh_mtu2_id_table[] = {> 
> >   };
> >   MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table);
> > 
> > +static const struct of_device_id sh_mtu2_of_table[] = {
> > +	{ .compatible = "renesas,mtu2" },
> > +	{ }
> > +};
> > +MODULE_DEVICE_TABLE(of, sh_mtu2_of_table);
> > +
> >   static struct platform_driver sh_mtu2_device_driver = {
> >   	.probe		= sh_mtu2_probe,
> >   	.remove		= sh_mtu2_remove,
> >   	.driver		= {
> >   		.name	= "sh_mtu2",
> > +		.of_match_table = of_match_ptr(sh_mtu2_of_table),
> 
> No need for of_match_ptr() since the table us not protected by #ifdef
> CONFIG_OF...

I'll fix that.

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 11/19] clocksource: sh_mtu2: Add DT support
@ 2014-06-16 14:40       ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sergei,

On Saturday 14 June 2014 21:00:20 Sergei Shtylyov wrote:
> On 06/14/2014 08:23 PM, Laurent Pinchart wrote:
> > Document DT bindings and parse them in the MTU2 driver.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > Tested-by: Wolfram Sang <wsa@sang-engineering.com>
> > ---
> > 
> >  .../devicetree/bindings/timer/renesas,mtu2.txt     | 40 +++++++++++++++++
> >  drivers/clocksource/sh_mtu2.c                      |  8 +++++
> >   2 files changed, 48 insertions(+)
> >   create mode 100644
> >   Documentation/devicetree/bindings/timer/renesas,mtu2.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
> > b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt new file mode
> > 100644
> > index 0000000..c5dd032
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
> > @@ -0,0 +1,40 @@
> > +* Renesas R-Car Multi-Function Timer Pulse Unit 2 (MTU2)
> > +
> > +The MTU2 is a multi-purpose, multi-channel timer/counter with
> > configurable
> > +clock inputs and programmable compare match.
> > +
> > +Channels share hardware resources but their counter and compare match
> > value
> > +are independent. The MTU2 hardware supports five channels indexed from 0
> > to 4.
> > +
> > +Required Properties:
> > +
> > +  - compatible: must contain "renesas,mtu2"
> > +
> > +  - reg: base address and length of the registers block for the timer
> > module.
> > +
> > +  - interrupt-parent, interrupts: interrupt specifiers for the timer, one
> > for
> > +    each entry in interrupt-names.
> 
> The "interrupt-parent" has never been a required property, it can and should
> be inherited from an upper level node.

Only when it makes sense (which is the case here). We need a standard wording 
to describe the interrupt-related properties. In the meantime I'll drop 
interrupt-parent.

> [...]
> 
> > diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
> > index ebdf9d1..79387af 100644
> > --- a/drivers/clocksource/sh_mtu2.c
> > +++ b/drivers/clocksource/sh_mtu2.c
> 
> [...]
> 
> > @@ -502,11 +503,18 @@ static const struct platform_device_id
> > sh_mtu2_id_table[] = {> 
> >   };
> >   MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table);
> > 
> > +static const struct of_device_id sh_mtu2_of_table[] = {
> > +	{ .compatible = "renesas,mtu2" },
> > +	{ }
> > +};
> > +MODULE_DEVICE_TABLE(of, sh_mtu2_of_table);
> > +
> >   static struct platform_driver sh_mtu2_device_driver = {
> >   	.probe		= sh_mtu2_probe,
> >   	.remove		= sh_mtu2_remove,
> >   	.driver		= {
> >   		.name	= "sh_mtu2",
> > +		.of_match_table = of_match_ptr(sh_mtu2_of_table),
> 
> No need for of_match_ptr() since the table us not protected by #ifdef
> CONFIG_OF...

I'll fix that.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 11/19] clocksource: sh_mtu2: Add DT support
  2014-06-16 14:40       ` Laurent Pinchart
@ 2014-06-16 14:50         ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sergei,

On Monday 16 June 2014 16:40:55 Laurent Pinchart wrote:
> On Saturday 14 June 2014 21:00:20 Sergei Shtylyov wrote:
> > On 06/14/2014 08:23 PM, Laurent Pinchart wrote:
> > > Document DT bindings and parse them in the MTU2 driver.
> > > 
> > > Signed-off-by: Laurent Pinchart
> > > <laurent.pinchart+renesas@ideasonboard.com>
> > > Tested-by: Wolfram Sang <wsa@sang-engineering.com>
> > > ---
> > > 
> > >  .../devicetree/bindings/timer/renesas,mtu2.txt     | 40 +++++++++++++++
> > >  drivers/clocksource/sh_mtu2.c                      |  8 +++++
> > >  
> > >   2 files changed, 48 insertions(+)
> > >   create mode 100644
> > >   Documentation/devicetree/bindings/timer/renesas,mtu2.txt

[snip]

> > > diff --git a/drivers/clocksource/sh_mtu2.c
> > > b/drivers/clocksource/sh_mtu2.c
> > > index ebdf9d1..79387af 100644
> > > --- a/drivers/clocksource/sh_mtu2.c
> > > +++ b/drivers/clocksource/sh_mtu2.c
> > 
> > [...]
> > 
> > > @@ -502,11 +503,18 @@ static const struct platform_device_id
> > > sh_mtu2_id_table[] = {
> > >   };
> > >   MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table);
> > > 
> > > +static const struct of_device_id sh_mtu2_of_table[] = {
> > > +	{ .compatible = "renesas,mtu2" },
> > > +	{ }
> > > +};
> > > +MODULE_DEVICE_TABLE(of, sh_mtu2_of_table);
> > > +
> > >   static struct platform_driver sh_mtu2_device_driver = {
> > >   	.probe		= sh_mtu2_probe,
> > >   	.remove		= sh_mtu2_remove,
> > >   	.driver		= {
> > >   		.name	= "sh_mtu2",
> > > +		.of_match_table = of_match_ptr(sh_mtu2_of_table),
> > 
> > No need for of_match_ptr() since the table us not protected by #ifdef
> > CONFIG_OF...
> 
> I'll fix that.

I spoke too fast. On non-OF platforms memory shouldn't be wasted by the OF 
match table. I'll mark the table as __maybe_unused and keep of_match_ptr().

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 11/19] clocksource: sh_mtu2: Add DT support
@ 2014-06-16 14:50         ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 14:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Sergei,

On Monday 16 June 2014 16:40:55 Laurent Pinchart wrote:
> On Saturday 14 June 2014 21:00:20 Sergei Shtylyov wrote:
> > On 06/14/2014 08:23 PM, Laurent Pinchart wrote:
> > > Document DT bindings and parse them in the MTU2 driver.
> > > 
> > > Signed-off-by: Laurent Pinchart
> > > <laurent.pinchart+renesas@ideasonboard.com>
> > > Tested-by: Wolfram Sang <wsa@sang-engineering.com>
> > > ---
> > > 
> > >  .../devicetree/bindings/timer/renesas,mtu2.txt     | 40 +++++++++++++++
> > >  drivers/clocksource/sh_mtu2.c                      |  8 +++++
> > >  
> > >   2 files changed, 48 insertions(+)
> > >   create mode 100644
> > >   Documentation/devicetree/bindings/timer/renesas,mtu2.txt

[snip]

> > > diff --git a/drivers/clocksource/sh_mtu2.c
> > > b/drivers/clocksource/sh_mtu2.c
> > > index ebdf9d1..79387af 100644
> > > --- a/drivers/clocksource/sh_mtu2.c
> > > +++ b/drivers/clocksource/sh_mtu2.c
> > 
> > [...]
> > 
> > > @@ -502,11 +503,18 @@ static const struct platform_device_id
> > > sh_mtu2_id_table[] = {
> > >   };
> > >   MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table);
> > > 
> > > +static const struct of_device_id sh_mtu2_of_table[] = {
> > > +	{ .compatible = "renesas,mtu2" },
> > > +	{ }
> > > +};
> > > +MODULE_DEVICE_TABLE(of, sh_mtu2_of_table);
> > > +
> > >   static struct platform_driver sh_mtu2_device_driver = {
> > >   	.probe		= sh_mtu2_probe,
> > >   	.remove		= sh_mtu2_remove,
> > >   	.driver		= {
> > >   		.name	= "sh_mtu2",
> > > +		.of_match_table = of_match_ptr(sh_mtu2_of_table),
> > 
> > No need for of_match_ptr() since the table us not protected by #ifdef
> > CONFIG_OF...
> 
> I'll fix that.

I spoke too fast. On non-OF platforms memory shouldn't be wasted by the OF 
match table. I'll mark the table as __maybe_unused and keep of_match_ptr().

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
  2014-06-16 14:22       ` Laurent Pinchart
  (?)
@ 2014-06-16 16:19         ` Geert Uytterhoeven
  -1 siblings, 0 replies; 76+ messages in thread
From: Geert Uytterhoeven @ 2014-06-16 16:19 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Laurent,

On Mon, Jun 16, 2014 at 4:22 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>> diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
>> index bf716ce..81714ce 100644
>> --- a/arch/arm/boot/dts/r8a7779.dtsi
>> +++ b/arch/arm/boot/dts/r8a7779.dtsi
>> @@ -269,9 +269,10 @@
>>       tmu0: timer@ffd80000 {
>>               compatible = "renesas,tmu";
>>               reg = <0xffd80000 0x30>;
>> -             interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 41 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 42 IRQ_TYPE_LEVEL_HIGH>;
>> +             interrupt-parent = <&gic>;
>> +             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";
>>
>> @@ -283,9 +284,10 @@
>>       tmu1: timer@ffd81000 {
>>               compatible = "renesas,tmu";
>>               reg = <0xffd81000 0x30>;
>> -             interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 45 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 46 IRQ_TYPE_LEVEL_HIGH>;
>> +             interrupt-parent = <&gic>;
>> +             interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 36 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 37 IRQ_TYPE_LEVEL_HIGH>;
>
> If I'm not mistaken the interrupts should be 36, 37 and 38.

(diving into the documentation)

Yes, probably 36, 37, and 38. I say "probably", as I find it non-trivial
to convert from docs to DT.

What happens with 35, which is "TMU21 (input capture)"?
As DT describes the hardware, shouldn't it be mentioned here?

>>               clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
>>               clock-names = "fck";
>>
>> @@ -296,10 +298,11 @@
>>
>>       tmu2: timer@ffd82000 {
>>               compatible = "renesas,tmu";
>> +             interrupt-parent = <&gic>;
>>               reg = <0xffd82000 0x30>;
>> -             interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 49 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 50 IRQ_TYPE_LEVEL_HIGH>;
>> +             interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 39 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 40 IRQ_TYPE_LEVEL_HIGH>;
>
> And 40, 41 and 42 here.

Likewise for "TMU51 (input capture)"?

>>               clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
>>               clock-names = "fck";

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
@ 2014-06-16 16:19         ` Geert Uytterhoeven
  0 siblings, 0 replies; 76+ messages in thread
From: Geert Uytterhoeven @ 2014-06-16 16:19 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Simon Horman, Laurent Pinchart, Linux-sh list, linux-arm-kernel,
	Daniel Lezcano, Thomas Gleixner, devicetree

Hi Laurent,

On Mon, Jun 16, 2014 at 4:22 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>> diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
>> index bf716ce..81714ce 100644
>> --- a/arch/arm/boot/dts/r8a7779.dtsi
>> +++ b/arch/arm/boot/dts/r8a7779.dtsi
>> @@ -269,9 +269,10 @@
>>       tmu0: timer@ffd80000 {
>>               compatible = "renesas,tmu";
>>               reg = <0xffd80000 0x30>;
>> -             interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 41 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 42 IRQ_TYPE_LEVEL_HIGH>;
>> +             interrupt-parent = <&gic>;
>> +             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";
>>
>> @@ -283,9 +284,10 @@
>>       tmu1: timer@ffd81000 {
>>               compatible = "renesas,tmu";
>>               reg = <0xffd81000 0x30>;
>> -             interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 45 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 46 IRQ_TYPE_LEVEL_HIGH>;
>> +             interrupt-parent = <&gic>;
>> +             interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 36 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 37 IRQ_TYPE_LEVEL_HIGH>;
>
> If I'm not mistaken the interrupts should be 36, 37 and 38.

(diving into the documentation)

Yes, probably 36, 37, and 38. I say "probably", as I find it non-trivial
to convert from docs to DT.

What happens with 35, which is "TMU21 (input capture)"?
As DT describes the hardware, shouldn't it be mentioned here?

>>               clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
>>               clock-names = "fck";
>>
>> @@ -296,10 +298,11 @@
>>
>>       tmu2: timer@ffd82000 {
>>               compatible = "renesas,tmu";
>> +             interrupt-parent = <&gic>;
>>               reg = <0xffd82000 0x30>;
>> -             interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 49 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 50 IRQ_TYPE_LEVEL_HIGH>;
>> +             interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 39 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 40 IRQ_TYPE_LEVEL_HIGH>;
>
> And 40, 41 and 42 here.

Likewise for "TMU51 (input capture)"?

>>               clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
>>               clock-names = "fck";

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
@ 2014-06-16 16:19         ` Geert Uytterhoeven
  0 siblings, 0 replies; 76+ messages in thread
From: Geert Uytterhoeven @ 2014-06-16 16:19 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Laurent,

On Mon, Jun 16, 2014 at 4:22 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>> diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
>> index bf716ce..81714ce 100644
>> --- a/arch/arm/boot/dts/r8a7779.dtsi
>> +++ b/arch/arm/boot/dts/r8a7779.dtsi
>> @@ -269,9 +269,10 @@
>>       tmu0: timer at ffd80000 {
>>               compatible = "renesas,tmu";
>>               reg = <0xffd80000 0x30>;
>> -             interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 41 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 42 IRQ_TYPE_LEVEL_HIGH>;
>> +             interrupt-parent = <&gic>;
>> +             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";
>>
>> @@ -283,9 +284,10 @@
>>       tmu1: timer at ffd81000 {
>>               compatible = "renesas,tmu";
>>               reg = <0xffd81000 0x30>;
>> -             interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 45 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 46 IRQ_TYPE_LEVEL_HIGH>;
>> +             interrupt-parent = <&gic>;
>> +             interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 36 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 37 IRQ_TYPE_LEVEL_HIGH>;
>
> If I'm not mistaken the interrupts should be 36, 37 and 38.

(diving into the documentation)

Yes, probably 36, 37, and 38. I say "probably", as I find it non-trivial
to convert from docs to DT.

What happens with 35, which is "TMU21 (input capture)"?
As DT describes the hardware, shouldn't it be mentioned here?

>>               clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
>>               clock-names = "fck";
>>
>> @@ -296,10 +298,11 @@
>>
>>       tmu2: timer at ffd82000 {
>>               compatible = "renesas,tmu";
>> +             interrupt-parent = <&gic>;
>>               reg = <0xffd82000 0x30>;
>> -             interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 49 IRQ_TYPE_LEVEL_HIGH>,
>> -                          <0 50 IRQ_TYPE_LEVEL_HIGH>;
>> +             interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 39 IRQ_TYPE_LEVEL_HIGH>,
>> +                          <0 40 IRQ_TYPE_LEVEL_HIGH>;
>
> And 40, 41 and 42 here.

Likewise for "TMU51 (input capture)"?

>>               clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
>>               clock-names = "fck";

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
  2014-06-16 16:19         ` Geert Uytterhoeven
  (?)
@ 2014-06-16 20:31           ` Laurent Pinchart
  -1 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 20:31 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Geert,

On Monday 16 June 2014 18:19:02 Geert Uytterhoeven wrote:
> On Mon, Jun 16, 2014 at 4:22 PM, Laurent Pinchart wrote:
> >> diff --git a/arch/arm/boot/dts/r8a7779.dtsi
> >> b/arch/arm/boot/dts/r8a7779.dtsi index bf716ce..81714ce 100644
> >> --- a/arch/arm/boot/dts/r8a7779.dtsi
> >> +++ b/arch/arm/boot/dts/r8a7779.dtsi
> >> @@ -269,9 +269,10 @@
> >>       tmu0: timer@ffd80000 {
> >>               compatible = "renesas,tmu";
> >>               reg = <0xffd80000 0x30>;
> >> -             interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 41 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 42 IRQ_TYPE_LEVEL_HIGH>;
> >> +             interrupt-parent = <&gic>;
> >> +             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";
> >> 
> >> @@ -283,9 +284,10 @@
> >>       tmu1: timer@ffd81000 {
> >>               compatible = "renesas,tmu";
> >>               reg = <0xffd81000 0x30>;
> >> -             interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 45 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 46 IRQ_TYPE_LEVEL_HIGH>;
> >> +             interrupt-parent = <&gic>;
> >> +             interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 36 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 37 IRQ_TYPE_LEVEL_HIGH>;
> > 
> > If I'm not mistaken the interrupts should be 36, 37 and 38.
> 
> (diving into the documentation)
> 
> Yes, probably 36, 37, and 38. I say "probably", as I find it non-trivial
> to convert from docs to DT.
> 
> What happens with 35, which is "TMU21 (input capture)"?
> As DT describes the hardware, shouldn't it be mentioned here?

Input capture isn't supported by the TMU driver yet. I haven't checked how the 
feature is implemented in the hardware, which is why I've left it out from the 
DT bindings for now.

> >>               clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> >>               clock-names = "fck";
> >> 
> >> @@ -296,10 +298,11 @@
> >> 
> >>       tmu2: timer@ffd82000 {
> >>               compatible = "renesas,tmu";
> >> +             interrupt-parent = <&gic>;
> >>               reg = <0xffd82000 0x30>;
> >> -             interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 49 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 50 IRQ_TYPE_LEVEL_HIGH>;
> >> +             interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 39 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 40 IRQ_TYPE_LEVEL_HIGH>;
> > 
> > And 40, 41 and 42 here.
> 
> Likewise for "TMU51 (input capture)"?
> 
> >>               clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> >>               clock-names = "fck";

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
@ 2014-06-16 20:31           ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 20:31 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Simon Horman, Laurent Pinchart, Linux-sh list, linux-arm-kernel,
	Daniel Lezcano, Thomas Gleixner, devicetree

Hi Geert,

On Monday 16 June 2014 18:19:02 Geert Uytterhoeven wrote:
> On Mon, Jun 16, 2014 at 4:22 PM, Laurent Pinchart wrote:
> >> diff --git a/arch/arm/boot/dts/r8a7779.dtsi
> >> b/arch/arm/boot/dts/r8a7779.dtsi index bf716ce..81714ce 100644
> >> --- a/arch/arm/boot/dts/r8a7779.dtsi
> >> +++ b/arch/arm/boot/dts/r8a7779.dtsi
> >> @@ -269,9 +269,10 @@
> >>       tmu0: timer@ffd80000 {
> >>               compatible = "renesas,tmu";
> >>               reg = <0xffd80000 0x30>;
> >> -             interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 41 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 42 IRQ_TYPE_LEVEL_HIGH>;
> >> +             interrupt-parent = <&gic>;
> >> +             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";
> >> 
> >> @@ -283,9 +284,10 @@
> >>       tmu1: timer@ffd81000 {
> >>               compatible = "renesas,tmu";
> >>               reg = <0xffd81000 0x30>;
> >> -             interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 45 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 46 IRQ_TYPE_LEVEL_HIGH>;
> >> +             interrupt-parent = <&gic>;
> >> +             interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 36 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 37 IRQ_TYPE_LEVEL_HIGH>;
> > 
> > If I'm not mistaken the interrupts should be 36, 37 and 38.
> 
> (diving into the documentation)
> 
> Yes, probably 36, 37, and 38. I say "probably", as I find it non-trivial
> to convert from docs to DT.
> 
> What happens with 35, which is "TMU21 (input capture)"?
> As DT describes the hardware, shouldn't it be mentioned here?

Input capture isn't supported by the TMU driver yet. I haven't checked how the 
feature is implemented in the hardware, which is why I've left it out from the 
DT bindings for now.

> >>               clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> >>               clock-names = "fck";
> >> 
> >> @@ -296,10 +298,11 @@
> >> 
> >>       tmu2: timer@ffd82000 {
> >>               compatible = "renesas,tmu";
> >> +             interrupt-parent = <&gic>;
> >>               reg = <0xffd82000 0x30>;
> >> -             interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 49 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 50 IRQ_TYPE_LEVEL_HIGH>;
> >> +             interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 39 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 40 IRQ_TYPE_LEVEL_HIGH>;
> > 
> > And 40, 41 and 42 here.
> 
> Likewise for "TMU51 (input capture)"?
> 
> >>               clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> >>               clock-names = "fck";

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
@ 2014-06-16 20:31           ` Laurent Pinchart
  0 siblings, 0 replies; 76+ messages in thread
From: Laurent Pinchart @ 2014-06-16 20:31 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Geert,

On Monday 16 June 2014 18:19:02 Geert Uytterhoeven wrote:
> On Mon, Jun 16, 2014 at 4:22 PM, Laurent Pinchart wrote:
> >> diff --git a/arch/arm/boot/dts/r8a7779.dtsi
> >> b/arch/arm/boot/dts/r8a7779.dtsi index bf716ce..81714ce 100644
> >> --- a/arch/arm/boot/dts/r8a7779.dtsi
> >> +++ b/arch/arm/boot/dts/r8a7779.dtsi
> >> @@ -269,9 +269,10 @@
> >>       tmu0: timer at ffd80000 {
> >>               compatible = "renesas,tmu";
> >>               reg = <0xffd80000 0x30>;
> >> -             interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 41 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 42 IRQ_TYPE_LEVEL_HIGH>;
> >> +             interrupt-parent = <&gic>;
> >> +             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";
> >> 
> >> @@ -283,9 +284,10 @@
> >>       tmu1: timer at ffd81000 {
> >>               compatible = "renesas,tmu";
> >>               reg = <0xffd81000 0x30>;
> >> -             interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 45 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 46 IRQ_TYPE_LEVEL_HIGH>;
> >> +             interrupt-parent = <&gic>;
> >> +             interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 36 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 37 IRQ_TYPE_LEVEL_HIGH>;
> > 
> > If I'm not mistaken the interrupts should be 36, 37 and 38.
> 
> (diving into the documentation)
> 
> Yes, probably 36, 37, and 38. I say "probably", as I find it non-trivial
> to convert from docs to DT.
> 
> What happens with 35, which is "TMU21 (input capture)"?
> As DT describes the hardware, shouldn't it be mentioned here?

Input capture isn't supported by the TMU driver yet. I haven't checked how the 
feature is implemented in the hardware, which is why I've left it out from the 
DT bindings for now.

> >>               clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> >>               clock-names = "fck";
> >> 
> >> @@ -296,10 +298,11 @@
> >> 
> >>       tmu2: timer at ffd82000 {
> >>               compatible = "renesas,tmu";
> >> +             interrupt-parent = <&gic>;
> >>               reg = <0xffd82000 0x30>;
> >> -             interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 49 IRQ_TYPE_LEVEL_HIGH>,
> >> -                          <0 50 IRQ_TYPE_LEVEL_HIGH>;
> >> +             interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 39 IRQ_TYPE_LEVEL_HIGH>,
> >> +                          <0 40 IRQ_TYPE_LEVEL_HIGH>;
> > 
> > And 40, 41 and 42 here.
> 
> Likewise for "TMU51 (input capture)"?
> 
> >>               clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> >>               clock-names = "fck";

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
  2014-06-16 14:22       ` Laurent Pinchart
  (?)
@ 2014-06-16 23:34         ` Simon Horman
  -1 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16 23:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 16, 2014 at 04:22:11PM +0200, Laurent Pinchart wrote:
> Hi Simon,
> 
> On Monday 16 June 2014 17:47:07 Simon Horman wrote:
> > On Sat, Jun 14, 2014 at 06:23:36PM +0200, Laurent Pinchart wrote:
> > > Add the TMU0, TMU1 and TMU2 counters to the r8a7779 device tree and make
> > > them disabled by default.
> > > 
> > > Signed-off-by: Laurent Pinchart
> > > <laurent.pinchart+renesas@ideasonboard.com>
> > > ---
> > > 
> > >  arch/arm/boot/dts/r8a7779.dtsi | 42 +++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 42 insertions(+)
> > > 
> > > diff --git a/arch/arm/boot/dts/r8a7779.dtsi
> > > b/arch/arm/boot/dts/r8a7779.dtsi index 94e2fc8..bf716ce 100644
> > > --- a/arch/arm/boot/dts/r8a7779.dtsi
> > > +++ b/arch/arm/boot/dts/r8a7779.dtsi
> > > @@ -266,6 +266,48 @@
> > >  		reg = <0xffc48000 0x38>;
> > >  	};
> > > 
> > > +	tmu0: timer@ffd80000 {
> > > +		compatible = "renesas,tmu";
> > > +		reg = <0xffd80000 0x30>;
> > > +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > > +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> > > +		clock-names = "fck";
> > > +
> > > +		#renesas,channels = <3>;
> > > +
> > > +		status = "disabled";
> > > +	};
> > > +
> > > +	tmu1: timer@ffd81000 {
> > > +		compatible = "renesas,tmu";
> > > +		reg = <0xffd81000 0x30>;
> > > +		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> > > +		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> > > +		clock-names = "fck";
> > > +
> > > +		#renesas,channels = <3>;
> > > +
> > > +		status = "disabled";
> > > +	};
> > > +
> > > +	tmu2: timer@ffd82000 {
> > > +		compatible = "renesas,tmu";
> > > +		reg = <0xffd82000 0x30>;
> > > +		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> > > +		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> > > +		clock-names = "fck";
> > > +
> > > +		#renesas,channels = <3>;
> > > +
> > > +		status = "disabled";
> > > +	};
> > > +
> > >  	sata: sata@fc600000 {
> > >  		compatible = "renesas,rcar-sata";
> > >  		reg = <0xfc600000 0x2000>;
> > 
> > There are no interrupt-parents in in the nodes above nodes
> > although the documentation of the binding has one in the example.
> > Is it just an oversight in this patch?
> 
> Not really.
> 
> The interrupt-parent property is required but can be inherited. Furthermore, 
> the interrupts-extended property can be used to replace the interrupts and 
> interrupt-parent properties. This should all be documented in the DT bindings, 
> but not by duplicating the full explanation in dozens of different flavours in 
> all bindings. We need standard wordings for common properties such as 
> interrupts, clocks or reg.

Thanks for the clarification, I'm fine with that.

> > I believe that the IRQ numbers are not correct.
> > 
> > In setup-r8a7779.c I see gic_iid(0x40). But above I see 40.
> > I think the correct value is 0x40 - 32 = 32. Likewise
> > for the other IRQs of tmu0. And looking at the documentaiton
> > this seems true for tmu1 and tmu2 too.
> >
> > I have successfully booted a marzen board with the following incremental
> > patch to the DT nodes.
> 
> You're right, sorry about that. I'll fix the interrupt numbers and resubmit. 
> The interrupt-parent is specified at the top level so there's no need to add 
> it to the TMU nodes.
> 
> > diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
> > index bf716ce..81714ce 100644
> > --- a/arch/arm/boot/dts/r8a7779.dtsi
> > +++ b/arch/arm/boot/dts/r8a7779.dtsi
> > @@ -269,9 +269,10 @@
> >  	tmu0: timer@ffd80000 {
> >  		compatible = "renesas,tmu";
> >  		reg = <0xffd80000 0x30>;
> > -		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > +		interrupt-parent = <&gic>;
> > +		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";
> > 
> > @@ -283,9 +284,10 @@
> >  	tmu1: timer@ffd81000 {
> >  		compatible = "renesas,tmu";
> >  		reg = <0xffd81000 0x30>;
> > -		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> > +		interrupt-parent = <&gic>;
> > +		interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 36 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 37 IRQ_TYPE_LEVEL_HIGH>;
> 
> If I'm not mistaken the interrupts should be 36, 37 and 38.

Yes, sorry about that.

> >  		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> >  		clock-names = "fck";
> > 
> > @@ -296,10 +298,11 @@
> > 
> >  	tmu2: timer@ffd82000 {
> >  		compatible = "renesas,tmu";
> > +		interrupt-parent = <&gic>;
> >  		reg = <0xffd82000 0x30>;
> > -		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> > +		interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 39 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 40 IRQ_TYPE_LEVEL_HIGH>;
> 
> And 40, 41 and 42 here.

Yes. I wonder how I managed to mess these up.

> >  		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> >  		clock-names = "fck";

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
@ 2014-06-16 23:34         ` Simon Horman
  0 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16 23:34 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Laurent Pinchart, linux-sh, linux-arm-kernel, Daniel Lezcano,
	Thomas Gleixner, devicetree

On Mon, Jun 16, 2014 at 04:22:11PM +0200, Laurent Pinchart wrote:
> Hi Simon,
> 
> On Monday 16 June 2014 17:47:07 Simon Horman wrote:
> > On Sat, Jun 14, 2014 at 06:23:36PM +0200, Laurent Pinchart wrote:
> > > Add the TMU0, TMU1 and TMU2 counters to the r8a7779 device tree and make
> > > them disabled by default.
> > > 
> > > Signed-off-by: Laurent Pinchart
> > > <laurent.pinchart+renesas@ideasonboard.com>
> > > ---
> > > 
> > >  arch/arm/boot/dts/r8a7779.dtsi | 42 +++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 42 insertions(+)
> > > 
> > > diff --git a/arch/arm/boot/dts/r8a7779.dtsi
> > > b/arch/arm/boot/dts/r8a7779.dtsi index 94e2fc8..bf716ce 100644
> > > --- a/arch/arm/boot/dts/r8a7779.dtsi
> > > +++ b/arch/arm/boot/dts/r8a7779.dtsi
> > > @@ -266,6 +266,48 @@
> > >  		reg = <0xffc48000 0x38>;
> > >  	};
> > > 
> > > +	tmu0: timer@ffd80000 {
> > > +		compatible = "renesas,tmu";
> > > +		reg = <0xffd80000 0x30>;
> > > +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > > +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> > > +		clock-names = "fck";
> > > +
> > > +		#renesas,channels = <3>;
> > > +
> > > +		status = "disabled";
> > > +	};
> > > +
> > > +	tmu1: timer@ffd81000 {
> > > +		compatible = "renesas,tmu";
> > > +		reg = <0xffd81000 0x30>;
> > > +		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> > > +		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> > > +		clock-names = "fck";
> > > +
> > > +		#renesas,channels = <3>;
> > > +
> > > +		status = "disabled";
> > > +	};
> > > +
> > > +	tmu2: timer@ffd82000 {
> > > +		compatible = "renesas,tmu";
> > > +		reg = <0xffd82000 0x30>;
> > > +		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> > > +		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> > > +		clock-names = "fck";
> > > +
> > > +		#renesas,channels = <3>;
> > > +
> > > +		status = "disabled";
> > > +	};
> > > +
> > >  	sata: sata@fc600000 {
> > >  		compatible = "renesas,rcar-sata";
> > >  		reg = <0xfc600000 0x2000>;
> > 
> > There are no interrupt-parents in in the nodes above nodes
> > although the documentation of the binding has one in the example.
> > Is it just an oversight in this patch?
> 
> Not really.
> 
> The interrupt-parent property is required but can be inherited. Furthermore, 
> the interrupts-extended property can be used to replace the interrupts and 
> interrupt-parent properties. This should all be documented in the DT bindings, 
> but not by duplicating the full explanation in dozens of different flavours in 
> all bindings. We need standard wordings for common properties such as 
> interrupts, clocks or reg.

Thanks for the clarification, I'm fine with that.

> > I believe that the IRQ numbers are not correct.
> > 
> > In setup-r8a7779.c I see gic_iid(0x40). But above I see 40.
> > I think the correct value is 0x40 - 32 = 32. Likewise
> > for the other IRQs of tmu0. And looking at the documentaiton
> > this seems true for tmu1 and tmu2 too.
> >
> > I have successfully booted a marzen board with the following incremental
> > patch to the DT nodes.
> 
> You're right, sorry about that. I'll fix the interrupt numbers and resubmit. 
> The interrupt-parent is specified at the top level so there's no need to add 
> it to the TMU nodes.
> 
> > diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
> > index bf716ce..81714ce 100644
> > --- a/arch/arm/boot/dts/r8a7779.dtsi
> > +++ b/arch/arm/boot/dts/r8a7779.dtsi
> > @@ -269,9 +269,10 @@
> >  	tmu0: timer@ffd80000 {
> >  		compatible = "renesas,tmu";
> >  		reg = <0xffd80000 0x30>;
> > -		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > +		interrupt-parent = <&gic>;
> > +		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";
> > 
> > @@ -283,9 +284,10 @@
> >  	tmu1: timer@ffd81000 {
> >  		compatible = "renesas,tmu";
> >  		reg = <0xffd81000 0x30>;
> > -		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> > +		interrupt-parent = <&gic>;
> > +		interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 36 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 37 IRQ_TYPE_LEVEL_HIGH>;
> 
> If I'm not mistaken the interrupts should be 36, 37 and 38.

Yes, sorry about that.

> >  		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> >  		clock-names = "fck";
> > 
> > @@ -296,10 +298,11 @@
> > 
> >  	tmu2: timer@ffd82000 {
> >  		compatible = "renesas,tmu";
> > +		interrupt-parent = <&gic>;
> >  		reg = <0xffd82000 0x30>;
> > -		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> > +		interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 39 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 40 IRQ_TYPE_LEVEL_HIGH>;
> 
> And 40, 41 and 42 here.

Yes. I wonder how I managed to mess these up.

> >  		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> >  		clock-names = "fck";

^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU devices to DT
@ 2014-06-16 23:34         ` Simon Horman
  0 siblings, 0 replies; 76+ messages in thread
From: Simon Horman @ 2014-06-16 23:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 16, 2014 at 04:22:11PM +0200, Laurent Pinchart wrote:
> Hi Simon,
> 
> On Monday 16 June 2014 17:47:07 Simon Horman wrote:
> > On Sat, Jun 14, 2014 at 06:23:36PM +0200, Laurent Pinchart wrote:
> > > Add the TMU0, TMU1 and TMU2 counters to the r8a7779 device tree and make
> > > them disabled by default.
> > > 
> > > Signed-off-by: Laurent Pinchart
> > > <laurent.pinchart+renesas@ideasonboard.com>
> > > ---
> > > 
> > >  arch/arm/boot/dts/r8a7779.dtsi | 42 +++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 42 insertions(+)
> > > 
> > > diff --git a/arch/arm/boot/dts/r8a7779.dtsi
> > > b/arch/arm/boot/dts/r8a7779.dtsi index 94e2fc8..bf716ce 100644
> > > --- a/arch/arm/boot/dts/r8a7779.dtsi
> > > +++ b/arch/arm/boot/dts/r8a7779.dtsi
> > > @@ -266,6 +266,48 @@
> > >  		reg = <0xffc48000 0x38>;
> > >  	};
> > > 
> > > +	tmu0: timer at ffd80000 {
> > > +		compatible = "renesas,tmu";
> > > +		reg = <0xffd80000 0x30>;
> > > +		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > > +		clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
> > > +		clock-names = "fck";
> > > +
> > > +		#renesas,channels = <3>;
> > > +
> > > +		status = "disabled";
> > > +	};
> > > +
> > > +	tmu1: timer at ffd81000 {
> > > +		compatible = "renesas,tmu";
> > > +		reg = <0xffd81000 0x30>;
> > > +		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> > > +		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> > > +		clock-names = "fck";
> > > +
> > > +		#renesas,channels = <3>;
> > > +
> > > +		status = "disabled";
> > > +	};
> > > +
> > > +	tmu2: timer at ffd82000 {
> > > +		compatible = "renesas,tmu";
> > > +		reg = <0xffd82000 0x30>;
> > > +		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> > > +			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> > > +		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> > > +		clock-names = "fck";
> > > +
> > > +		#renesas,channels = <3>;
> > > +
> > > +		status = "disabled";
> > > +	};
> > > +
> > >  	sata: sata at fc600000 {
> > >  		compatible = "renesas,rcar-sata";
> > >  		reg = <0xfc600000 0x2000>;
> > 
> > There are no interrupt-parents in in the nodes above nodes
> > although the documentation of the binding has one in the example.
> > Is it just an oversight in this patch?
> 
> Not really.
> 
> The interrupt-parent property is required but can be inherited. Furthermore, 
> the interrupts-extended property can be used to replace the interrupts and 
> interrupt-parent properties. This should all be documented in the DT bindings, 
> but not by duplicating the full explanation in dozens of different flavours in 
> all bindings. We need standard wordings for common properties such as 
> interrupts, clocks or reg.

Thanks for the clarification, I'm fine with that.

> > I believe that the IRQ numbers are not correct.
> > 
> > In setup-r8a7779.c I see gic_iid(0x40). But above I see 40.
> > I think the correct value is 0x40 - 32 = 32. Likewise
> > for the other IRQs of tmu0. And looking at the documentaiton
> > this seems true for tmu1 and tmu2 too.
> >
> > I have successfully booted a marzen board with the following incremental
> > patch to the DT nodes.
> 
> You're right, sorry about that. I'll fix the interrupt numbers and resubmit. 
> The interrupt-parent is specified at the top level so there's no need to add 
> it to the TMU nodes.
> 
> > diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
> > index bf716ce..81714ce 100644
> > --- a/arch/arm/boot/dts/r8a7779.dtsi
> > +++ b/arch/arm/boot/dts/r8a7779.dtsi
> > @@ -269,9 +269,10 @@
> >  	tmu0: timer at ffd80000 {
> >  		compatible = "renesas,tmu";
> >  		reg = <0xffd80000 0x30>;
> > -		interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 41 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 42 IRQ_TYPE_LEVEL_HIGH>;
> > +		interrupt-parent = <&gic>;
> > +		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";
> > 
> > @@ -283,9 +284,10 @@
> >  	tmu1: timer at ffd81000 {
> >  		compatible = "renesas,tmu";
> >  		reg = <0xffd81000 0x30>;
> > -		interrupts = <0 44 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 45 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 46 IRQ_TYPE_LEVEL_HIGH>;
> > +		interrupt-parent = <&gic>;
> > +		interrupts = <0 35 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 36 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 37 IRQ_TYPE_LEVEL_HIGH>;
> 
> If I'm not mistaken the interrupts should be 36, 37 and 38.

Yes, sorry about that.

> >  		clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
> >  		clock-names = "fck";
> > 
> > @@ -296,10 +298,11 @@
> > 
> >  	tmu2: timer at ffd82000 {
> >  		compatible = "renesas,tmu";
> > +		interrupt-parent = <&gic>;
> >  		reg = <0xffd82000 0x30>;
> > -		interrupts = <0 48 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 49 IRQ_TYPE_LEVEL_HIGH>,
> > -			     <0 50 IRQ_TYPE_LEVEL_HIGH>;
> > +		interrupts = <0 38 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 39 IRQ_TYPE_LEVEL_HIGH>,
> > +			     <0 40 IRQ_TYPE_LEVEL_HIGH>;
> 
> And 40, 41 and 42 here.

Yes. I wonder how I managed to mess these up.

> >  		clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
> >  		clock-names = "fck";

^ permalink raw reply	[flat|nested] 76+ messages in thread

end of thread, other threads:[~2014-06-16 23:34 UTC | newest]

Thread overview: 76+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-14 16:23 [PATCH v3 00/19] Renesas CMT, MTU2 and TMU timers DT support Laurent Pinchart
2014-06-14 16:23 ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 01/19] clocksource: sh_tmu: Fix channel IRQ retrieval in legacy case Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 02/19] clocksource: sh_cmt: Drop support for legacy platform data Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 03/19] clocksource: sh_cmt: Replace global spinlock with a per-device spinlock Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 04/19] clocksource: sh_tmu: Drop support for legacy platform data Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 05/19] clocksource: sh_tmu: Replace global spinlock with a per-device spinlock Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 06/19] clocksource: sh_mtu2: Drop support for legacy platform data Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 07/19] clocksource: sh_mtu2: Replace global spinlock with a per-device spinlock Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 08/19] clocksource: shmobile: Remove unused sh_timer_config members Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 09/19] clocksource: sh_cmt: Add DT support Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 10/19] clocksource: sh_tmu: " Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-16  8:34   ` Simon Horman
2014-06-16  8:34     ` Simon Horman
2014-06-16 14:32     ` Laurent Pinchart
2014-06-16 14:32       ` Laurent Pinchart
2014-06-16  8:48   ` Simon Horman
2014-06-16  8:48     ` Simon Horman
2014-06-16 14:24     ` Laurent Pinchart
2014-06-16 14:24       ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 11/19] clocksource: sh_mtu2: " Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 17:00   ` Sergei Shtylyov
2014-06-14 17:00     ` Sergei Shtylyov
2014-06-16 14:40     ` Laurent Pinchart
2014-06-16 14:40       ` Laurent Pinchart
2014-06-16 14:50       ` Laurent Pinchart
2014-06-16 14:50         ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 12/19] ARM: shmobile: r8a7790: Add CMT devices to DT Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:54   ` Sergei Shtylyov
2014-06-14 16:54     ` Sergei Shtylyov
2014-06-16 14:38     ` Laurent Pinchart
2014-06-16 14:38       ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 13/19] ARM: shmobile: r8a7791: " Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:55   ` Sergei Shtylyov
2014-06-14 16:55     ` Sergei Shtylyov
2014-06-14 16:23 ` [PATCH v3 14/19] ARM: shmobile: r8a7779: Add TMU " Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-16  8:47   ` Simon Horman
2014-06-16  8:47     ` Simon Horman
2014-06-16 14:22     ` Laurent Pinchart
2014-06-16 14:22       ` Laurent Pinchart
2014-06-16 14:22       ` Laurent Pinchart
2014-06-16 16:19       ` Geert Uytterhoeven
2014-06-16 16:19         ` Geert Uytterhoeven
2014-06-16 16:19         ` Geert Uytterhoeven
2014-06-16 20:31         ` Laurent Pinchart
2014-06-16 20:31           ` Laurent Pinchart
2014-06-16 20:31           ` Laurent Pinchart
2014-06-16 23:34       ` Simon Horman
2014-06-16 23:34         ` Simon Horman
2014-06-16 23:34         ` Simon Horman
2014-06-14 16:23 ` [PATCH v3 15/19] ARM: shmobile: r7s72100: Add MTU2 device " Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 16/19] ARM: shmobile: lager-reference: Enable CMT0 in device tree Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 17/19] ARM: shmobile: koelsch-reference: " Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 18/19] ARM: shmobile: marzen-reference: Enable TMU0 " Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-14 16:23 ` [PATCH v3 19/19] ARM: shmobile: genmai-reference: Enable MTU2 " Laurent Pinchart
2014-06-14 16:23   ` Laurent Pinchart
2014-06-16  9:00 ` [PATCH v3 00/19] Renesas CMT, MTU2 and TMU timers DT support Simon Horman
2014-06-16  9:00   ` Simon Horman

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.