All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] arm: Add basic support for Mediatek Cortex-A7 SoCs
@ 2014-04-09 19:45 ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	rdunlap, linux, daniel.lezcano, tglx, matthias.bgg,
	thierry.reding, florian.vaussard, jic23, jason, andrew,
	silvio.fricke, heiko.stuebner, olof, sebastian.hesselbarth,
	devicetree, linux-doc, linux-arm-kernel

This patch set adds basic support for the Mediatek Cortex-A7 SoCs.
Support is quite basic, as the only components working up to now are the
timers and the low-level debug via UART.

The patch series is build against torvalds/master tree


Matthias Brugger (4):
  clocksource: Add support for the Mediatek SoCs
  dt-bindings: add mtk-timer bindings
  arm: add basic support for Mediatek MT6589 boards
  arm: mediatek: Add earlyprintk support for MT6589

 .../bindings/timer/mediatek,mtk-timer.txt          |   19 ++
 .../devicetree/bindings/vendor-prefixes.txt        |    1 +
 arch/arm/Kconfig                                   |    2 +
 arch/arm/Kconfig.debug                             |   49 +++-
 arch/arm/Makefile                                  |    1 +
 arch/arm/boot/dts/mtk6589.dtsi                     |  105 +++++++++
 arch/arm/include/debug/mediatek.S                  |   38 +++
 arch/arm/mach-mediatek/Kconfig                     |   14 ++
 arch/arm/mach-mediatek/Makefile                    |    1 +
 arch/arm/mach-mediatek/mediatek.c                  |   40 ++++
 drivers/clocksource/Kconfig                        |    4 +
 drivers/clocksource/Makefile                       |    1 +
 drivers/clocksource/mtk_timer.c                    |  248 ++++++++++++++++++++
 13 files changed, 521 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
 create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
 create mode 100644 arch/arm/include/debug/mediatek.S
 create mode 100644 arch/arm/mach-mediatek/Kconfig
 create mode 100644 arch/arm/mach-mediatek/Makefile
 create mode 100644 arch/arm/mach-mediatek/mediatek.c
 create mode 100644 drivers/clocksource/mtk_timer.c

-- 
1.7.9.5


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

* [PATCH 0/4] arm: Add basic support for Mediatek Cortex-A7 SoCs
@ 2014-04-09 19:45 ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-arm-kernel

This patch set adds basic support for the Mediatek Cortex-A7 SoCs.
Support is quite basic, as the only components working up to now are the
timers and the low-level debug via UART.

The patch series is build against torvalds/master tree


Matthias Brugger (4):
  clocksource: Add support for the Mediatek SoCs
  dt-bindings: add mtk-timer bindings
  arm: add basic support for Mediatek MT6589 boards
  arm: mediatek: Add earlyprintk support for MT6589

 .../bindings/timer/mediatek,mtk-timer.txt          |   19 ++
 .../devicetree/bindings/vendor-prefixes.txt        |    1 +
 arch/arm/Kconfig                                   |    2 +
 arch/arm/Kconfig.debug                             |   49 +++-
 arch/arm/Makefile                                  |    1 +
 arch/arm/boot/dts/mtk6589.dtsi                     |  105 +++++++++
 arch/arm/include/debug/mediatek.S                  |   38 +++
 arch/arm/mach-mediatek/Kconfig                     |   14 ++
 arch/arm/mach-mediatek/Makefile                    |    1 +
 arch/arm/mach-mediatek/mediatek.c                  |   40 ++++
 drivers/clocksource/Kconfig                        |    4 +
 drivers/clocksource/Makefile                       |    1 +
 drivers/clocksource/mtk_timer.c                    |  248 ++++++++++++++++++++
 13 files changed, 521 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
 create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
 create mode 100644 arch/arm/include/debug/mediatek.S
 create mode 100644 arch/arm/mach-mediatek/Kconfig
 create mode 100644 arch/arm/mach-mediatek/Makefile
 create mode 100644 arch/arm/mach-mediatek/mediatek.c
 create mode 100644 drivers/clocksource/mtk_timer.c

-- 
1.7.9.5

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

* [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
  2014-04-09 19:45 ` Matthias Brugger
  (?)
@ 2014-04-09 19:45   ` Matthias Brugger
  -1 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	rdunlap, linux, daniel.lezcano, tglx, matthias.bgg,
	thierry.reding, florian.vaussard, jic23, jason, andrew,
	silvio.fricke, heiko.stuebner, olof, sebastian.hesselbarth,
	devicetree, linux-doc, linux-arm-kernel

This patch adds a clock source and clock event for the timer found
on the Mediatek SoCs.

The Mediatek General Porpose Timer block provides five 32 bit timers and
one 64 bit timer.

Two 32 bit timers are used:
TIMER1: clock events supporting periodic and oneshot events
TIMER2: clock source configured as a free running counter

The General Porpose Timer block can be run with two clocks. A 13 MHz system
clock and the RTC clock running at 32 KHz. This implementation uses the system
clock.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
 drivers/clocksource/Kconfig     |    4 +
 drivers/clocksource/Makefile    |    1 +
 drivers/clocksource/mtk_timer.c |  248 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 253 insertions(+)
 create mode 100644 drivers/clocksource/mtk_timer.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 96918e1..bb29321 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -144,6 +144,10 @@ config VF_PIT_TIMER
 config SYS_SUPPORTS_SH_CMT
         bool
 
+config MTK_TIMER
+	bool
+
+
 config SYS_SUPPORTS_SH_MTU2
         bool
 
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 98cb6c5..619d302 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_CLKSRC_EXYNOS_MCT)	+= exynos_mct.o
 obj-$(CONFIG_CLKSRC_SAMSUNG_PWM)	+= samsung_pwm_timer.o
 obj-$(CONFIG_VF_PIT_TIMER)	+= vf_pit_timer.o
 obj-$(CONFIG_CLKSRC_QCOM)	+= qcom-timer.o
+obj-$(CONFIG_MTK_TIMER)		+= mtk_timer.o
 
 obj-$(CONFIG_ARM_ARCH_TIMER)		+= arm_arch_timer.o
 obj-$(CONFIG_ARM_GLOBAL_TIMER)		+= arm_global_timer.o
diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
new file mode 100644
index 0000000..bf901e3
--- /dev/null
+++ b/drivers/clocksource/mtk_timer.c
@@ -0,0 +1,248 @@
+/*
+ * Mediatek SoCs General-Purpose Timer handling.
+ *
+ * Copyright (C) 2014 Matthias Brugger
+ *
+ * Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk.h>
+#include <linux/clockchips.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/irqreturn.h>
+#include <linux/sched_clock.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+
+#define GPT_IRQ_EN_REG		0x00
+#define GPT_IRQ_ENABLE(val)	BIT(val-1)
+#define GPT_IRQ_ST_REG		0x04
+#define GPT_IRQ_ACK_REG		0x08
+#define GPT_IRQ_ACK(val)	BIT(val-1)
+
+#define TIMER_CTRL_REG(val)	(0x10 * val)
+#define TIMER_CTRL_OP(val)	(((val) & 0x3) << 4)
+#define TIMER_CTRL_OP_ONESHOT	(0)
+#define TIMER_CTRL_OP_REPEAT	(1)
+#define TIMER_CTRL_OP_KEEPGO	(2)
+#define TIMER_CTRL_OP_FREERUN	(3)
+#define TIMER_CTRL_CLEAR	(2)
+#define TIMER_CTRL_ENABLE	(1)
+#define TIMER_CTRL_DISABLE	(0)
+
+#define TIMER_CLK_REG(val)	(0x04 + (0x10 * val))
+#define TIMER_CLK_SRC(val)	(((val) & 0x1) << 4)
+#define TIMER_CLK_SRC_SYS13M	(0)
+#define TIMER_CLK_SRC_RTC32K	(1)
+#define TIMER_CLK_DIV1		(0x0)
+#define TIMER_CLK_DIV2		(0x1)
+#define TIMER_CLK_DIV3		(0x2)
+#define TIMER_CLK_DIV4		(0x3)
+#define TIMER_CLK_DIV5		(0x4)
+#define TIMER_CLK_DIV6		(0x5)
+#define TIMER_CLK_DIV7		(0x6)
+#define TIMER_CLK_DIV8		(0x7)
+#define TIMER_CLK_DIV9		(0x8)
+#define TIMER_CLK_DIV10		(0x9)
+#define TIMER_CLK_DIV11		(0xA)
+#define TIMER_CLK_DIV12		(0xB)
+#define TIMER_CLK_DIV13		(0xC)
+#define TIMER_CLK_DIV16		(0xD)
+#define TIMER_CLK_DIV32		(0xE)
+#define TIMER_CLK_DIV64		(0xF)
+
+#define TIMER_CNT_REG(val)	(0x08 + (0x10 * val))
+#define TIMER_CMP_REG(val)	(0x0C + (0x10 * val))
+
+#define GPT_CLK_EVT	1
+#define GPT_CLK_SRC	2
+
+static void __iomem *gpt_base;
+static u32 ticks_per_jiffy;
+
+static void mtk_clkevt_time_stop(u8 timer)
+{
+	u32 val = readl(gpt_base + TIMER_CTRL_REG(timer));
+	writel(val & ~TIMER_CTRL_ENABLE, gpt_base + TIMER_CTRL_REG(timer));
+}
+
+static void mtk_clkevt_time_setup(unsigned long delay, u8 timer)
+{
+	writel(delay, gpt_base + TIMER_CMP_REG(timer));
+}
+
+static void mtk_clkevt_time_start(bool periodic, u8 timer)
+{
+	u32 val;
+
+	/* Acknowledge interrupt */
+	writel(GPT_IRQ_ACK(timer), gpt_base + GPT_IRQ_ACK_REG);
+
+	val = readl(gpt_base + TIMER_CTRL_REG(timer));
+
+	/* Clear 2 bit timer operation mode field */
+	val &= ~TIMER_CTRL_OP(0x3);
+
+	if (periodic)
+		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT);
+	else
+		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_ONESHOT);
+
+	writel(val | TIMER_CTRL_ENABLE | TIMER_CTRL_CLEAR,
+	       gpt_base + TIMER_CTRL_REG(timer));
+}
+
+static void mtk_clkevt_mode(enum clock_event_mode mode,
+			      struct clock_event_device *clk)
+{
+	mtk_clkevt_time_stop(GPT_CLK_EVT);
+
+	switch (mode) {
+	case CLOCK_EVT_MODE_PERIODIC:
+		mtk_clkevt_time_setup(ticks_per_jiffy, GPT_CLK_EVT);
+		mtk_clkevt_time_start(true, GPT_CLK_EVT);
+		break;
+	case CLOCK_EVT_MODE_ONESHOT:
+		mtk_clkevt_time_start(false, GPT_CLK_EVT);
+		break;
+	case CLOCK_EVT_MODE_UNUSED:
+	case CLOCK_EVT_MODE_SHUTDOWN:
+	default:
+		/* No more interrupts will occur as source is disabled */
+		break;
+	}
+}
+
+static int mtk_clkevt_next_event(unsigned long evt,
+				   struct clock_event_device *unused)
+{
+	mtk_clkevt_time_stop(GPT_CLK_EVT);
+	mtk_clkevt_time_setup(evt, GPT_CLK_EVT);
+	mtk_clkevt_time_start(false, GPT_CLK_EVT);
+
+	return 0;
+}
+
+static struct clock_event_device mtk_clockevent = {
+	.name = "mtk_tick",
+	.rating = 300,
+	.shift = 32,
+	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
+	.set_mode = mtk_clkevt_mode,
+	.set_next_event = mtk_clkevt_next_event,
+};
+
+
+static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
+{
+	struct clock_event_device *evt = (struct clock_event_device *)dev_id;
+
+	/* Acknowledge timer0 irq */
+	writel(GPT_IRQ_ACK(GPT_CLK_EVT), gpt_base + GPT_IRQ_ACK_REG);
+	evt->event_handler(evt);
+
+	return IRQ_HANDLED;
+}
+
+static void mtk_timer_global_reset(void)
+{
+	/* Disable all interrupts */
+	writel(0x0, gpt_base + GPT_IRQ_EN_REG);
+	/* Acknowledge all interrupts */
+	writel(0x3f, gpt_base + GPT_IRQ_ACK_REG);
+}
+
+static void mtk_timer_reset(u8 timer)
+{
+	writel(TIMER_CTRL_CLEAR | TIMER_CTRL_DISABLE,
+		gpt_base + TIMER_CTRL_REG(timer));
+	writel(0x0, gpt_base + TIMER_CMP_REG(timer));
+}
+
+static struct irqaction mtk_timer_irq = {
+	.name = "mtk_timer0",
+	.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
+	.handler = mtk_timer_interrupt,
+	.dev_id = &mtk_clockevent,
+};
+
+static u32 mtk_timer_sched_read(void)
+{
+	return readl(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC));
+}
+
+static void __init mtk_timer_init(struct device_node *node)
+{
+	unsigned long rate = 0;
+	struct clk *clk;
+	int ret, irq;
+	u32 val;
+
+	gpt_base = of_iomap(node, 0);
+	if (!gpt_base)
+		panic("Can't map registers");
+
+	irq = irq_of_parse_and_map(node, 0);
+	if (irq <= 0)
+		panic("Can't parse IRQ");
+
+	clk = of_clk_get_by_name(node, "sys_clk");
+	if (IS_ERR(clk))
+		panic("Can't get timer clock");
+	clk_prepare_enable(clk);
+
+	rate = clk_get_rate(clk);
+
+	mtk_timer_global_reset();
+
+	/* Configure clock source */
+	mtk_timer_reset(GPT_CLK_SRC);
+
+	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
+			gpt_base + TIMER_CLK_REG(GPT_CLK_SRC));
+
+	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_FREERUN) | TIMER_CTRL_ENABLE,
+				gpt_base + TIMER_CTRL_REG(GPT_CLK_SRC));
+
+	clocksource_mmio_init(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), node->name,
+			      rate, 300, 32, clocksource_mmio_readl_up);
+
+	ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
+
+	/* Configure clock event */
+	mtk_timer_reset(GPT_CLK_EVT);
+
+	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
+			gpt_base + TIMER_CLK_REG(GPT_CLK_EVT));
+	writel(0, gpt_base + TIMER_CMP_REG(GPT_CLK_EVT));
+
+	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT) | TIMER_CTRL_ENABLE,
+			gpt_base + TIMER_CTRL_REG(GPT_CLK_EVT));
+
+	ret = setup_irq(irq, &mtk_timer_irq);
+	if (ret)
+		pr_warn("failed to setup irq %d\n", irq);
+
+	/* Enable timer0 interrupt */
+	val = readl(gpt_base + GPT_IRQ_EN_REG);
+	writel(val | GPT_IRQ_ENABLE(GPT_CLK_EVT), gpt_base + GPT_IRQ_EN_REG);
+
+	mtk_clockevent.cpumask = cpumask_of(0);
+
+	clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
+					0xffffffff);
+}
+CLOCKSOURCE_OF_DECLARE(mtk_mt6589, "mediatek,mtk6589-timer", mtk_timer_init);
+
-- 
1.7.9.5


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

* [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 19:45   ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: mark.rutland, andrew, linux-doc, thierry.reding, heiko.stuebner,
	linux, daniel.lezcano, florian.vaussard, sebastian.hesselbarth,
	devicetree, jason, pawel.moll, ijc+devicetree, robh+dt,
	matthias.bgg, tglx, linux-arm-kernel, rdunlap, silvio.fricke,
	galak, olof, jic23

This patch adds a clock source and clock event for the timer found
on the Mediatek SoCs.

The Mediatek General Porpose Timer block provides five 32 bit timers and
one 64 bit timer.

Two 32 bit timers are used:
TIMER1: clock events supporting periodic and oneshot events
TIMER2: clock source configured as a free running counter

The General Porpose Timer block can be run with two clocks. A 13 MHz system
clock and the RTC clock running at 32 KHz. This implementation uses the system
clock.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
 drivers/clocksource/Kconfig     |    4 +
 drivers/clocksource/Makefile    |    1 +
 drivers/clocksource/mtk_timer.c |  248 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 253 insertions(+)
 create mode 100644 drivers/clocksource/mtk_timer.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 96918e1..bb29321 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -144,6 +144,10 @@ config VF_PIT_TIMER
 config SYS_SUPPORTS_SH_CMT
         bool
 
+config MTK_TIMER
+	bool
+
+
 config SYS_SUPPORTS_SH_MTU2
         bool
 
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 98cb6c5..619d302 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_CLKSRC_EXYNOS_MCT)	+= exynos_mct.o
 obj-$(CONFIG_CLKSRC_SAMSUNG_PWM)	+= samsung_pwm_timer.o
 obj-$(CONFIG_VF_PIT_TIMER)	+= vf_pit_timer.o
 obj-$(CONFIG_CLKSRC_QCOM)	+= qcom-timer.o
+obj-$(CONFIG_MTK_TIMER)		+= mtk_timer.o
 
 obj-$(CONFIG_ARM_ARCH_TIMER)		+= arm_arch_timer.o
 obj-$(CONFIG_ARM_GLOBAL_TIMER)		+= arm_global_timer.o
diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
new file mode 100644
index 0000000..bf901e3
--- /dev/null
+++ b/drivers/clocksource/mtk_timer.c
@@ -0,0 +1,248 @@
+/*
+ * Mediatek SoCs General-Purpose Timer handling.
+ *
+ * Copyright (C) 2014 Matthias Brugger
+ *
+ * Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk.h>
+#include <linux/clockchips.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/irqreturn.h>
+#include <linux/sched_clock.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+
+#define GPT_IRQ_EN_REG		0x00
+#define GPT_IRQ_ENABLE(val)	BIT(val-1)
+#define GPT_IRQ_ST_REG		0x04
+#define GPT_IRQ_ACK_REG		0x08
+#define GPT_IRQ_ACK(val)	BIT(val-1)
+
+#define TIMER_CTRL_REG(val)	(0x10 * val)
+#define TIMER_CTRL_OP(val)	(((val) & 0x3) << 4)
+#define TIMER_CTRL_OP_ONESHOT	(0)
+#define TIMER_CTRL_OP_REPEAT	(1)
+#define TIMER_CTRL_OP_KEEPGO	(2)
+#define TIMER_CTRL_OP_FREERUN	(3)
+#define TIMER_CTRL_CLEAR	(2)
+#define TIMER_CTRL_ENABLE	(1)
+#define TIMER_CTRL_DISABLE	(0)
+
+#define TIMER_CLK_REG(val)	(0x04 + (0x10 * val))
+#define TIMER_CLK_SRC(val)	(((val) & 0x1) << 4)
+#define TIMER_CLK_SRC_SYS13M	(0)
+#define TIMER_CLK_SRC_RTC32K	(1)
+#define TIMER_CLK_DIV1		(0x0)
+#define TIMER_CLK_DIV2		(0x1)
+#define TIMER_CLK_DIV3		(0x2)
+#define TIMER_CLK_DIV4		(0x3)
+#define TIMER_CLK_DIV5		(0x4)
+#define TIMER_CLK_DIV6		(0x5)
+#define TIMER_CLK_DIV7		(0x6)
+#define TIMER_CLK_DIV8		(0x7)
+#define TIMER_CLK_DIV9		(0x8)
+#define TIMER_CLK_DIV10		(0x9)
+#define TIMER_CLK_DIV11		(0xA)
+#define TIMER_CLK_DIV12		(0xB)
+#define TIMER_CLK_DIV13		(0xC)
+#define TIMER_CLK_DIV16		(0xD)
+#define TIMER_CLK_DIV32		(0xE)
+#define TIMER_CLK_DIV64		(0xF)
+
+#define TIMER_CNT_REG(val)	(0x08 + (0x10 * val))
+#define TIMER_CMP_REG(val)	(0x0C + (0x10 * val))
+
+#define GPT_CLK_EVT	1
+#define GPT_CLK_SRC	2
+
+static void __iomem *gpt_base;
+static u32 ticks_per_jiffy;
+
+static void mtk_clkevt_time_stop(u8 timer)
+{
+	u32 val = readl(gpt_base + TIMER_CTRL_REG(timer));
+	writel(val & ~TIMER_CTRL_ENABLE, gpt_base + TIMER_CTRL_REG(timer));
+}
+
+static void mtk_clkevt_time_setup(unsigned long delay, u8 timer)
+{
+	writel(delay, gpt_base + TIMER_CMP_REG(timer));
+}
+
+static void mtk_clkevt_time_start(bool periodic, u8 timer)
+{
+	u32 val;
+
+	/* Acknowledge interrupt */
+	writel(GPT_IRQ_ACK(timer), gpt_base + GPT_IRQ_ACK_REG);
+
+	val = readl(gpt_base + TIMER_CTRL_REG(timer));
+
+	/* Clear 2 bit timer operation mode field */
+	val &= ~TIMER_CTRL_OP(0x3);
+
+	if (periodic)
+		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT);
+	else
+		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_ONESHOT);
+
+	writel(val | TIMER_CTRL_ENABLE | TIMER_CTRL_CLEAR,
+	       gpt_base + TIMER_CTRL_REG(timer));
+}
+
+static void mtk_clkevt_mode(enum clock_event_mode mode,
+			      struct clock_event_device *clk)
+{
+	mtk_clkevt_time_stop(GPT_CLK_EVT);
+
+	switch (mode) {
+	case CLOCK_EVT_MODE_PERIODIC:
+		mtk_clkevt_time_setup(ticks_per_jiffy, GPT_CLK_EVT);
+		mtk_clkevt_time_start(true, GPT_CLK_EVT);
+		break;
+	case CLOCK_EVT_MODE_ONESHOT:
+		mtk_clkevt_time_start(false, GPT_CLK_EVT);
+		break;
+	case CLOCK_EVT_MODE_UNUSED:
+	case CLOCK_EVT_MODE_SHUTDOWN:
+	default:
+		/* No more interrupts will occur as source is disabled */
+		break;
+	}
+}
+
+static int mtk_clkevt_next_event(unsigned long evt,
+				   struct clock_event_device *unused)
+{
+	mtk_clkevt_time_stop(GPT_CLK_EVT);
+	mtk_clkevt_time_setup(evt, GPT_CLK_EVT);
+	mtk_clkevt_time_start(false, GPT_CLK_EVT);
+
+	return 0;
+}
+
+static struct clock_event_device mtk_clockevent = {
+	.name = "mtk_tick",
+	.rating = 300,
+	.shift = 32,
+	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
+	.set_mode = mtk_clkevt_mode,
+	.set_next_event = mtk_clkevt_next_event,
+};
+
+
+static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
+{
+	struct clock_event_device *evt = (struct clock_event_device *)dev_id;
+
+	/* Acknowledge timer0 irq */
+	writel(GPT_IRQ_ACK(GPT_CLK_EVT), gpt_base + GPT_IRQ_ACK_REG);
+	evt->event_handler(evt);
+
+	return IRQ_HANDLED;
+}
+
+static void mtk_timer_global_reset(void)
+{
+	/* Disable all interrupts */
+	writel(0x0, gpt_base + GPT_IRQ_EN_REG);
+	/* Acknowledge all interrupts */
+	writel(0x3f, gpt_base + GPT_IRQ_ACK_REG);
+}
+
+static void mtk_timer_reset(u8 timer)
+{
+	writel(TIMER_CTRL_CLEAR | TIMER_CTRL_DISABLE,
+		gpt_base + TIMER_CTRL_REG(timer));
+	writel(0x0, gpt_base + TIMER_CMP_REG(timer));
+}
+
+static struct irqaction mtk_timer_irq = {
+	.name = "mtk_timer0",
+	.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
+	.handler = mtk_timer_interrupt,
+	.dev_id = &mtk_clockevent,
+};
+
+static u32 mtk_timer_sched_read(void)
+{
+	return readl(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC));
+}
+
+static void __init mtk_timer_init(struct device_node *node)
+{
+	unsigned long rate = 0;
+	struct clk *clk;
+	int ret, irq;
+	u32 val;
+
+	gpt_base = of_iomap(node, 0);
+	if (!gpt_base)
+		panic("Can't map registers");
+
+	irq = irq_of_parse_and_map(node, 0);
+	if (irq <= 0)
+		panic("Can't parse IRQ");
+
+	clk = of_clk_get_by_name(node, "sys_clk");
+	if (IS_ERR(clk))
+		panic("Can't get timer clock");
+	clk_prepare_enable(clk);
+
+	rate = clk_get_rate(clk);
+
+	mtk_timer_global_reset();
+
+	/* Configure clock source */
+	mtk_timer_reset(GPT_CLK_SRC);
+
+	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
+			gpt_base + TIMER_CLK_REG(GPT_CLK_SRC));
+
+	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_FREERUN) | TIMER_CTRL_ENABLE,
+				gpt_base + TIMER_CTRL_REG(GPT_CLK_SRC));
+
+	clocksource_mmio_init(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), node->name,
+			      rate, 300, 32, clocksource_mmio_readl_up);
+
+	ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
+
+	/* Configure clock event */
+	mtk_timer_reset(GPT_CLK_EVT);
+
+	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
+			gpt_base + TIMER_CLK_REG(GPT_CLK_EVT));
+	writel(0, gpt_base + TIMER_CMP_REG(GPT_CLK_EVT));
+
+	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT) | TIMER_CTRL_ENABLE,
+			gpt_base + TIMER_CTRL_REG(GPT_CLK_EVT));
+
+	ret = setup_irq(irq, &mtk_timer_irq);
+	if (ret)
+		pr_warn("failed to setup irq %d\n", irq);
+
+	/* Enable timer0 interrupt */
+	val = readl(gpt_base + GPT_IRQ_EN_REG);
+	writel(val | GPT_IRQ_ENABLE(GPT_CLK_EVT), gpt_base + GPT_IRQ_EN_REG);
+
+	mtk_clockevent.cpumask = cpumask_of(0);
+
+	clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
+					0xffffffff);
+}
+CLOCKSOURCE_OF_DECLARE(mtk_mt6589, "mediatek,mtk6589-timer", mtk_timer_init);
+
-- 
1.7.9.5

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

* [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 19:45   ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds a clock source and clock event for the timer found
on the Mediatek SoCs.

The Mediatek General Porpose Timer block provides five 32 bit timers and
one 64 bit timer.

Two 32 bit timers are used:
TIMER1: clock events supporting periodic and oneshot events
TIMER2: clock source configured as a free running counter

The General Porpose Timer block can be run with two clocks. A 13 MHz system
clock and the RTC clock running at 32 KHz. This implementation uses the system
clock.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
 drivers/clocksource/Kconfig     |    4 +
 drivers/clocksource/Makefile    |    1 +
 drivers/clocksource/mtk_timer.c |  248 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 253 insertions(+)
 create mode 100644 drivers/clocksource/mtk_timer.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 96918e1..bb29321 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -144,6 +144,10 @@ config VF_PIT_TIMER
 config SYS_SUPPORTS_SH_CMT
         bool
 
+config MTK_TIMER
+	bool
+
+
 config SYS_SUPPORTS_SH_MTU2
         bool
 
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 98cb6c5..619d302 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_CLKSRC_EXYNOS_MCT)	+= exynos_mct.o
 obj-$(CONFIG_CLKSRC_SAMSUNG_PWM)	+= samsung_pwm_timer.o
 obj-$(CONFIG_VF_PIT_TIMER)	+= vf_pit_timer.o
 obj-$(CONFIG_CLKSRC_QCOM)	+= qcom-timer.o
+obj-$(CONFIG_MTK_TIMER)		+= mtk_timer.o
 
 obj-$(CONFIG_ARM_ARCH_TIMER)		+= arm_arch_timer.o
 obj-$(CONFIG_ARM_GLOBAL_TIMER)		+= arm_global_timer.o
diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
new file mode 100644
index 0000000..bf901e3
--- /dev/null
+++ b/drivers/clocksource/mtk_timer.c
@@ -0,0 +1,248 @@
+/*
+ * Mediatek SoCs General-Purpose Timer handling.
+ *
+ * Copyright (C) 2014 Matthias Brugger
+ *
+ * Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk.h>
+#include <linux/clockchips.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/irqreturn.h>
+#include <linux/sched_clock.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+
+#define GPT_IRQ_EN_REG		0x00
+#define GPT_IRQ_ENABLE(val)	BIT(val-1)
+#define GPT_IRQ_ST_REG		0x04
+#define GPT_IRQ_ACK_REG		0x08
+#define GPT_IRQ_ACK(val)	BIT(val-1)
+
+#define TIMER_CTRL_REG(val)	(0x10 * val)
+#define TIMER_CTRL_OP(val)	(((val) & 0x3) << 4)
+#define TIMER_CTRL_OP_ONESHOT	(0)
+#define TIMER_CTRL_OP_REPEAT	(1)
+#define TIMER_CTRL_OP_KEEPGO	(2)
+#define TIMER_CTRL_OP_FREERUN	(3)
+#define TIMER_CTRL_CLEAR	(2)
+#define TIMER_CTRL_ENABLE	(1)
+#define TIMER_CTRL_DISABLE	(0)
+
+#define TIMER_CLK_REG(val)	(0x04 + (0x10 * val))
+#define TIMER_CLK_SRC(val)	(((val) & 0x1) << 4)
+#define TIMER_CLK_SRC_SYS13M	(0)
+#define TIMER_CLK_SRC_RTC32K	(1)
+#define TIMER_CLK_DIV1		(0x0)
+#define TIMER_CLK_DIV2		(0x1)
+#define TIMER_CLK_DIV3		(0x2)
+#define TIMER_CLK_DIV4		(0x3)
+#define TIMER_CLK_DIV5		(0x4)
+#define TIMER_CLK_DIV6		(0x5)
+#define TIMER_CLK_DIV7		(0x6)
+#define TIMER_CLK_DIV8		(0x7)
+#define TIMER_CLK_DIV9		(0x8)
+#define TIMER_CLK_DIV10		(0x9)
+#define TIMER_CLK_DIV11		(0xA)
+#define TIMER_CLK_DIV12		(0xB)
+#define TIMER_CLK_DIV13		(0xC)
+#define TIMER_CLK_DIV16		(0xD)
+#define TIMER_CLK_DIV32		(0xE)
+#define TIMER_CLK_DIV64		(0xF)
+
+#define TIMER_CNT_REG(val)	(0x08 + (0x10 * val))
+#define TIMER_CMP_REG(val)	(0x0C + (0x10 * val))
+
+#define GPT_CLK_EVT	1
+#define GPT_CLK_SRC	2
+
+static void __iomem *gpt_base;
+static u32 ticks_per_jiffy;
+
+static void mtk_clkevt_time_stop(u8 timer)
+{
+	u32 val = readl(gpt_base + TIMER_CTRL_REG(timer));
+	writel(val & ~TIMER_CTRL_ENABLE, gpt_base + TIMER_CTRL_REG(timer));
+}
+
+static void mtk_clkevt_time_setup(unsigned long delay, u8 timer)
+{
+	writel(delay, gpt_base + TIMER_CMP_REG(timer));
+}
+
+static void mtk_clkevt_time_start(bool periodic, u8 timer)
+{
+	u32 val;
+
+	/* Acknowledge interrupt */
+	writel(GPT_IRQ_ACK(timer), gpt_base + GPT_IRQ_ACK_REG);
+
+	val = readl(gpt_base + TIMER_CTRL_REG(timer));
+
+	/* Clear 2 bit timer operation mode field */
+	val &= ~TIMER_CTRL_OP(0x3);
+
+	if (periodic)
+		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT);
+	else
+		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_ONESHOT);
+
+	writel(val | TIMER_CTRL_ENABLE | TIMER_CTRL_CLEAR,
+	       gpt_base + TIMER_CTRL_REG(timer));
+}
+
+static void mtk_clkevt_mode(enum clock_event_mode mode,
+			      struct clock_event_device *clk)
+{
+	mtk_clkevt_time_stop(GPT_CLK_EVT);
+
+	switch (mode) {
+	case CLOCK_EVT_MODE_PERIODIC:
+		mtk_clkevt_time_setup(ticks_per_jiffy, GPT_CLK_EVT);
+		mtk_clkevt_time_start(true, GPT_CLK_EVT);
+		break;
+	case CLOCK_EVT_MODE_ONESHOT:
+		mtk_clkevt_time_start(false, GPT_CLK_EVT);
+		break;
+	case CLOCK_EVT_MODE_UNUSED:
+	case CLOCK_EVT_MODE_SHUTDOWN:
+	default:
+		/* No more interrupts will occur as source is disabled */
+		break;
+	}
+}
+
+static int mtk_clkevt_next_event(unsigned long evt,
+				   struct clock_event_device *unused)
+{
+	mtk_clkevt_time_stop(GPT_CLK_EVT);
+	mtk_clkevt_time_setup(evt, GPT_CLK_EVT);
+	mtk_clkevt_time_start(false, GPT_CLK_EVT);
+
+	return 0;
+}
+
+static struct clock_event_device mtk_clockevent = {
+	.name = "mtk_tick",
+	.rating = 300,
+	.shift = 32,
+	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
+	.set_mode = mtk_clkevt_mode,
+	.set_next_event = mtk_clkevt_next_event,
+};
+
+
+static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
+{
+	struct clock_event_device *evt = (struct clock_event_device *)dev_id;
+
+	/* Acknowledge timer0 irq */
+	writel(GPT_IRQ_ACK(GPT_CLK_EVT), gpt_base + GPT_IRQ_ACK_REG);
+	evt->event_handler(evt);
+
+	return IRQ_HANDLED;
+}
+
+static void mtk_timer_global_reset(void)
+{
+	/* Disable all interrupts */
+	writel(0x0, gpt_base + GPT_IRQ_EN_REG);
+	/* Acknowledge all interrupts */
+	writel(0x3f, gpt_base + GPT_IRQ_ACK_REG);
+}
+
+static void mtk_timer_reset(u8 timer)
+{
+	writel(TIMER_CTRL_CLEAR | TIMER_CTRL_DISABLE,
+		gpt_base + TIMER_CTRL_REG(timer));
+	writel(0x0, gpt_base + TIMER_CMP_REG(timer));
+}
+
+static struct irqaction mtk_timer_irq = {
+	.name = "mtk_timer0",
+	.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
+	.handler = mtk_timer_interrupt,
+	.dev_id = &mtk_clockevent,
+};
+
+static u32 mtk_timer_sched_read(void)
+{
+	return readl(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC));
+}
+
+static void __init mtk_timer_init(struct device_node *node)
+{
+	unsigned long rate = 0;
+	struct clk *clk;
+	int ret, irq;
+	u32 val;
+
+	gpt_base = of_iomap(node, 0);
+	if (!gpt_base)
+		panic("Can't map registers");
+
+	irq = irq_of_parse_and_map(node, 0);
+	if (irq <= 0)
+		panic("Can't parse IRQ");
+
+	clk = of_clk_get_by_name(node, "sys_clk");
+	if (IS_ERR(clk))
+		panic("Can't get timer clock");
+	clk_prepare_enable(clk);
+
+	rate = clk_get_rate(clk);
+
+	mtk_timer_global_reset();
+
+	/* Configure clock source */
+	mtk_timer_reset(GPT_CLK_SRC);
+
+	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
+			gpt_base + TIMER_CLK_REG(GPT_CLK_SRC));
+
+	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_FREERUN) | TIMER_CTRL_ENABLE,
+				gpt_base + TIMER_CTRL_REG(GPT_CLK_SRC));
+
+	clocksource_mmio_init(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), node->name,
+			      rate, 300, 32, clocksource_mmio_readl_up);
+
+	ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
+
+	/* Configure clock event */
+	mtk_timer_reset(GPT_CLK_EVT);
+
+	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
+			gpt_base + TIMER_CLK_REG(GPT_CLK_EVT));
+	writel(0, gpt_base + TIMER_CMP_REG(GPT_CLK_EVT));
+
+	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT) | TIMER_CTRL_ENABLE,
+			gpt_base + TIMER_CTRL_REG(GPT_CLK_EVT));
+
+	ret = setup_irq(irq, &mtk_timer_irq);
+	if (ret)
+		pr_warn("failed to setup irq %d\n", irq);
+
+	/* Enable timer0 interrupt */
+	val = readl(gpt_base + GPT_IRQ_EN_REG);
+	writel(val | GPT_IRQ_ENABLE(GPT_CLK_EVT), gpt_base + GPT_IRQ_EN_REG);
+
+	mtk_clockevent.cpumask = cpumask_of(0);
+
+	clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
+					0xffffffff);
+}
+CLOCKSOURCE_OF_DECLARE(mtk_mt6589, "mediatek,mtk6589-timer", mtk_timer_init);
+
-- 
1.7.9.5

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

* [PATCH 2/4] dt-bindings: add mtk-timer bindings
@ 2014-04-09 19:45   ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	rdunlap, linux, daniel.lezcano, tglx, matthias.bgg,
	thierry.reding, florian.vaussard, jic23, jason, andrew,
	silvio.fricke, heiko.stuebner, olof, sebastian.hesselbarth,
	devicetree, linux-doc, linux-arm-kernel

Add binding documentation for the General Porpose Timer driver of
the Mediatek SoCs.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
 .../bindings/timer/mediatek,mtk-timer.txt          |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt

diff --git a/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
new file mode 100644
index 0000000..db3c836
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
@@ -0,0 +1,19 @@
+Mediatek MT6598, MT6577 and MT6572 Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "mediatek,mtk6589-timer"
+- reg: Should contain location and length for timers register.
+- clock-names : Must include the following entries:
+  "sysclk" (13 MHz system clock),
+  "rtcclk" (32 KHz RTC clock).
+
+Examples:
+
+	timer {
+		compatible = "mediatek,mtk6589-timer";
+		reg = <0x10008000 0x80>;
+		interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&system_clk>, <&rtc-clk>;
+		clock-names = "sysclk", "rtcclk";
+	};
-- 
1.7.9.5


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

* [PATCH 2/4] dt-bindings: add mtk-timer bindings
@ 2014-04-09 19:45   ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, rdunlap-wEGCiKHe2LqWVfeAwA7xHQ,
	linux-lFZ/pmaqli7XmaaqVzeoHQ,
	daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A,
	tglx-hfZtesqFncYOwBW4kG4KsQ, matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w,
	thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	florian.vaussard-p8DiymsW2f8, jic23-DgEjT+Ai2ygdnm+yROfE0A,
	jason-NLaQJdtUoK4Be96aLqz0jA, andrew-g2DYL2Zd6BY,
	silvio.fricke-Re5JQEeQqe8AvxtiuMwx3w, heiko.stuebner-K3U4GQvHnyU,
	olof-nZhT3qVonbNeoWH0uzbU5w,
	sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Add binding documentation for the General Porpose Timer driver of
the Mediatek SoCs.

Signed-off-by: Matthias Brugger <matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 .../bindings/timer/mediatek,mtk-timer.txt          |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt

diff --git a/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
new file mode 100644
index 0000000..db3c836
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
@@ -0,0 +1,19 @@
+Mediatek MT6598, MT6577 and MT6572 Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "mediatek,mtk6589-timer"
+- reg: Should contain location and length for timers register.
+- clock-names : Must include the following entries:
+  "sysclk" (13 MHz system clock),
+  "rtcclk" (32 KHz RTC clock).
+
+Examples:
+
+	timer {
+		compatible = "mediatek,mtk6589-timer";
+		reg = <0x10008000 0x80>;
+		interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&system_clk>, <&rtc-clk>;
+		clock-names = "sysclk", "rtcclk";
+	};
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 2/4] dt-bindings: add mtk-timer bindings
@ 2014-04-09 19:45   ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-arm-kernel

Add binding documentation for the General Porpose Timer driver of
the Mediatek SoCs.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
 .../bindings/timer/mediatek,mtk-timer.txt          |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt

diff --git a/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
new file mode 100644
index 0000000..db3c836
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
@@ -0,0 +1,19 @@
+Mediatek MT6598, MT6577 and MT6572 Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "mediatek,mtk6589-timer"
+- reg: Should contain location and length for timers register.
+- clock-names : Must include the following entries:
+  "sysclk" (13 MHz system clock),
+  "rtcclk" (32 KHz RTC clock).
+
+Examples:
+
+	timer {
+		compatible = "mediatek,mtk6589-timer";
+		reg = <0x10008000 0x80>;
+		interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&system_clk>, <&rtc-clk>;
+		clock-names = "sysclk", "rtcclk";
+	};
-- 
1.7.9.5

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-09 19:45 ` Matthias Brugger
@ 2014-04-09 19:45   ` Matthias Brugger
  -1 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	rdunlap, linux, daniel.lezcano, tglx, matthias.bgg,
	thierry.reding, florian.vaussard, jic23, jason, andrew,
	silvio.fricke, heiko.stuebner, olof, sebastian.hesselbarth,
	devicetree, linux-doc, linux-arm-kernel

This adds a generic devicetree board file and a dtsi for boards
based on the MT6589 SoCs from Mediatek.

Apart from the generic parts (gic, clocks) the only component
currently supported are the timers.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
 .../devicetree/bindings/vendor-prefixes.txt        |    1 +
 arch/arm/Kconfig                                   |    2 +
 arch/arm/Makefile                                  |    1 +
 arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++
 arch/arm/mach-mediatek/Kconfig                     |   14 +++
 arch/arm/mach-mediatek/Makefile                    |    1 +
 arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
 7 files changed, 164 insertions(+)
 create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
 create mode 100644 arch/arm/mach-mediatek/Kconfig
 create mode 100644 arch/arm/mach-mediatek/Makefile
 create mode 100644 arch/arm/mach-mediatek/mediatek.c

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 0f01c9b..af48801 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -67,6 +67,7 @@ linux	Linux-specific binding
 lsi	LSI Corp. (LSI Logic)
 marvell	Marvell Technology Group Ltd.
 maxim	Maxim Integrated Products
+mediatek	MediaTek Inc.
 microchip	Microchip Technology Inc.
 mosaixtech	Mosaix Technologies, Inc.
 moxa	Moxa
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5db05f6a..04d46ec 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
 
 source "arch/arm/mach-imx/Kconfig"
 
+source "arch/arm/mach-mediatek/Kconfig"
+
 source "arch/arm/mach-mxs/Kconfig"
 
 source "arch/arm/mach-netx/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 41c1931..8ce9774 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)		+= msm
 machine-$(CONFIG_ARCH_MV78XX0)		+= mv78xx0
 machine-$(CONFIG_ARCH_MVEBU)		+= mvebu
 machine-$(CONFIG_ARCH_MXC)		+= imx
+machine-$(CONFIG_ARCH_MEDIATEK)		+= mediatek
 machine-$(CONFIG_ARCH_MXS)		+= mxs
 machine-$(CONFIG_ARCH_NETX)		+= netx
 machine-$(CONFIG_ARCH_NOMADIK)		+= nomadik
diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
new file mode 100644
index 0000000..6dbb74f
--- /dev/null
+++ b/arch/arm/boot/dts/mtk6589.dtsi
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include "skeleton.dtsi"
+
+/ {
+	compatible = "mediatek,mt6589";
+	interrupt-parent = <&gic>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			next-level-cache = <&L2>;
+			reg = <0x0>;
+		};
+		cpu@1 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			next-level-cache = <&L2>;
+			reg = <0x1>;
+		};
+		cpu@2 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			next-level-cache = <&L2>;
+			reg = <0x2>;
+		};
+		cpu@3 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			next-level-cache = <&L2>;
+			reg = <0x3>;
+		};
+
+	};
+
+	clocks {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		system_clk: system_clk {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+			clock-output-names = "system_clk";
+		};
+
+		rtc_clk: rtc_clk {
+			compatible = "fixed-clock";
+			clock-frequency = <32000>;
+			#clock-cells = <0>;
+			clock-output-names = "rtc_clk";
+		};
+	};
+
+	soc {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "simple-bus";
+		clock-ranges;
+		ranges;
+
+		gic: interrupt-controller@10212000 {
+			compatible = "arm,cortex-a9-gic";
+			interrupt-controller;
+			#interrupt-cells = <3>;
+			reg = <0x10211000 0x1000>,
+			      <0x10212000 0x1000>;
+		};
+
+		L2: l2-cache-controller@1020e000 {
+			compatible = "arm,pl310-cache";
+			reg = <0x1020e000 0x1000>;
+			cache-unified;
+			cache-level = <2>;
+		};
+
+		timer: timer@10008000 {
+			compatible = "mediatek,mtk6589-timer";
+			reg = <0x10008000 0x80>;
+			interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
+			clocks = <&system_clk>, <&rtc_clk>;
+			clock-names = "sys_clk", "rtc_clk";
+		};
+	};
+};
diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
new file mode 100644
index 0000000..c0139ca
--- /dev/null
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -0,0 +1,14 @@
+config ARCH_MEDIATEK
+	bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
+	select ARCH_REQUIRE_GPIOLIB
+	select ARM_GIC
+	select CACHE_L2X0
+	select HAVE_ARM_TWD if LOCAL_TIMERS
+	select HAVE_SMP
+	select LOCAL_TIMERS if SMP
+	select COMMON_CLK
+	select GENERIC_CLOCKEVENTS
+	select MTK_TIMER
+	select CLKSRC_MMIO
+	help
+	  Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
new file mode 100644
index 0000000..43e619f
--- /dev/null
+++ b/arch/arm/mach-mediatek/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
new file mode 100644
index 0000000..f630403
--- /dev/null
+++ b/arch/arm/mach-mediatek/mediatek.c
@@ -0,0 +1,40 @@
+/*
+ * Device Tree support for Mediatek SoCs
+ *
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/of_platform.h>
+#include <linux/irqchip.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/hardware/cache-l2x0.h>
+
+static void __init mediatek_dt_init(void)
+{
+	l2x0_of_init(0, ~0);
+	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+}
+
+static const char * const mediatek_board_dt_compat[] = {
+	"mediatek,mt6589",
+	NULL,
+};
+
+DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
+	.init_machine	= mediatek_dt_init,
+	.dt_compat	= mediatek_board_dt_compat,
+MACHINE_END
-- 
1.7.9.5


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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-09 19:45   ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-arm-kernel

This adds a generic devicetree board file and a dtsi for boards
based on the MT6589 SoCs from Mediatek.

Apart from the generic parts (gic, clocks) the only component
currently supported are the timers.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
 .../devicetree/bindings/vendor-prefixes.txt        |    1 +
 arch/arm/Kconfig                                   |    2 +
 arch/arm/Makefile                                  |    1 +
 arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++
 arch/arm/mach-mediatek/Kconfig                     |   14 +++
 arch/arm/mach-mediatek/Makefile                    |    1 +
 arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
 7 files changed, 164 insertions(+)
 create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
 create mode 100644 arch/arm/mach-mediatek/Kconfig
 create mode 100644 arch/arm/mach-mediatek/Makefile
 create mode 100644 arch/arm/mach-mediatek/mediatek.c

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 0f01c9b..af48801 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -67,6 +67,7 @@ linux	Linux-specific binding
 lsi	LSI Corp. (LSI Logic)
 marvell	Marvell Technology Group Ltd.
 maxim	Maxim Integrated Products
+mediatek	MediaTek Inc.
 microchip	Microchip Technology Inc.
 mosaixtech	Mosaix Technologies, Inc.
 moxa	Moxa
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5db05f6a..04d46ec 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
 
 source "arch/arm/mach-imx/Kconfig"
 
+source "arch/arm/mach-mediatek/Kconfig"
+
 source "arch/arm/mach-mxs/Kconfig"
 
 source "arch/arm/mach-netx/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 41c1931..8ce9774 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)		+= msm
 machine-$(CONFIG_ARCH_MV78XX0)		+= mv78xx0
 machine-$(CONFIG_ARCH_MVEBU)		+= mvebu
 machine-$(CONFIG_ARCH_MXC)		+= imx
+machine-$(CONFIG_ARCH_MEDIATEK)		+= mediatek
 machine-$(CONFIG_ARCH_MXS)		+= mxs
 machine-$(CONFIG_ARCH_NETX)		+= netx
 machine-$(CONFIG_ARCH_NOMADIK)		+= nomadik
diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
new file mode 100644
index 0000000..6dbb74f
--- /dev/null
+++ b/arch/arm/boot/dts/mtk6589.dtsi
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include "skeleton.dtsi"
+
+/ {
+	compatible = "mediatek,mt6589";
+	interrupt-parent = <&gic>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu at 0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			next-level-cache = <&L2>;
+			reg = <0x0>;
+		};
+		cpu at 1 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			next-level-cache = <&L2>;
+			reg = <0x1>;
+		};
+		cpu at 2 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			next-level-cache = <&L2>;
+			reg = <0x2>;
+		};
+		cpu at 3 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			next-level-cache = <&L2>;
+			reg = <0x3>;
+		};
+
+	};
+
+	clocks {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		system_clk: system_clk {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+			clock-output-names = "system_clk";
+		};
+
+		rtc_clk: rtc_clk {
+			compatible = "fixed-clock";
+			clock-frequency = <32000>;
+			#clock-cells = <0>;
+			clock-output-names = "rtc_clk";
+		};
+	};
+
+	soc {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "simple-bus";
+		clock-ranges;
+		ranges;
+
+		gic: interrupt-controller at 10212000 {
+			compatible = "arm,cortex-a9-gic";
+			interrupt-controller;
+			#interrupt-cells = <3>;
+			reg = <0x10211000 0x1000>,
+			      <0x10212000 0x1000>;
+		};
+
+		L2: l2-cache-controller at 1020e000 {
+			compatible = "arm,pl310-cache";
+			reg = <0x1020e000 0x1000>;
+			cache-unified;
+			cache-level = <2>;
+		};
+
+		timer: timer at 10008000 {
+			compatible = "mediatek,mtk6589-timer";
+			reg = <0x10008000 0x80>;
+			interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
+			clocks = <&system_clk>, <&rtc_clk>;
+			clock-names = "sys_clk", "rtc_clk";
+		};
+	};
+};
diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
new file mode 100644
index 0000000..c0139ca
--- /dev/null
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -0,0 +1,14 @@
+config ARCH_MEDIATEK
+	bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
+	select ARCH_REQUIRE_GPIOLIB
+	select ARM_GIC
+	select CACHE_L2X0
+	select HAVE_ARM_TWD if LOCAL_TIMERS
+	select HAVE_SMP
+	select LOCAL_TIMERS if SMP
+	select COMMON_CLK
+	select GENERIC_CLOCKEVENTS
+	select MTK_TIMER
+	select CLKSRC_MMIO
+	help
+	  Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
new file mode 100644
index 0000000..43e619f
--- /dev/null
+++ b/arch/arm/mach-mediatek/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
new file mode 100644
index 0000000..f630403
--- /dev/null
+++ b/arch/arm/mach-mediatek/mediatek.c
@@ -0,0 +1,40 @@
+/*
+ * Device Tree support for Mediatek SoCs
+ *
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/of_platform.h>
+#include <linux/irqchip.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/hardware/cache-l2x0.h>
+
+static void __init mediatek_dt_init(void)
+{
+	l2x0_of_init(0, ~0);
+	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+}
+
+static const char * const mediatek_board_dt_compat[] = {
+	"mediatek,mt6589",
+	NULL,
+};
+
+DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
+	.init_machine	= mediatek_dt_init,
+	.dt_compat	= mediatek_board_dt_compat,
+MACHINE_END
-- 
1.7.9.5

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

* [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589
  2014-04-09 19:45 ` Matthias Brugger
@ 2014-04-09 19:45   ` Matthias Brugger
  -1 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	rdunlap, linux, daniel.lezcano, tglx, matthias.bgg,
	thierry.reding, florian.vaussard, jic23, jason, andrew,
	silvio.fricke, heiko.stuebner, olof, sebastian.hesselbarth,
	devicetree, linux-doc, linux-arm-kernel

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
 arch/arm/Kconfig.debug            |   49 +++++++++++++++++++++++++++++++++++--
 arch/arm/include/debug/mediatek.S |   38 ++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/include/debug/mediatek.S

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 4a2fc0b..dc51495 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -797,6 +797,38 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on Ux500 based platforms.
 
+	config DEBUG_MTK6589_UART0
+		depends on ARCH_MEDIATEK
+		bool "Mediatek mt6589 UART0"
+		select DEBUG_UART_MEDIATEK
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Mediatek mt6589 based platforms.
+
+	config DEBUG_MTK6589_UART1
+		depends on ARCH_MEDIATEK
+		bool "Mediatek mt6589 UART1"
+		select DEBUG_UART_MEDIATEK
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Mediatek mt6589 based platforms.
+
+	config DEBUG_MTK6589_UART2
+		depends on ARCH_MEDIATEK
+		bool "Mediatek mt6589 UART2"
+		select DEBUG_UART_MEDIATEK
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Mediatek mt6589 based platforms.
+
+	config DEBUG_MTK6589_UART3
+		depends on ARCH_MEDIATEK
+		bool "Mediatek mt6589 UART3"
+		select DEBUG_UART_MEDIATEK
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Mediatek mt6589 based platforms.
+
 	config DEBUG_VEXPRESS_UART0_DETECT
 		bool "Autodetect UART0 on Versatile Express Cortex-A core tiles"
 		depends on ARCH_VEXPRESS && CPU_CP15_MMU
@@ -954,6 +986,10 @@ config DEBUG_MSM_UART
 	bool
 	depends on ARCH_MSM || ARCH_QCOM
 
+config DEBUG_UART_MEDIATEK
+	bool
+	depends on ARCH_MEDIATEK
+
 config DEBUG_LL_INCLUDE
 	string
 	default "debug/8250.S" if DEBUG_LL_UART_8250 || DEBUG_UART_8250
@@ -971,6 +1007,7 @@ config DEBUG_LL_INCLUDE
 				 DEBUG_IMX53_UART ||\
 				 DEBUG_IMX6Q_UART || \
 				 DEBUG_IMX6SL_UART
+	default "debug/mediatek.S" if DEBUG_UART_MEDIATEK
 	default "debug/msm.S" if DEBUG_MSM_UART
 	default "debug/omap2plus.S" if DEBUG_OMAP2PLUS_UART
 	default "debug/sirf.S" if DEBUG_SIRFPRIMA2_UART1 || DEBUG_SIRFMARCO_UART1
@@ -1043,6 +1080,10 @@ config DEBUG_UART_PHYS
 	default 0xd0012000 if DEBUG_MVEBU_UART
 	default 0xd4017000 if DEBUG_MMP_UART2
 	default 0xd4018000 if DEBUG_MMP_UART3
+	default 0x11006000 if DEBUG_MTK6589_UART0
+	default 0x11007000 if DEBUG_MTK6589_UART1
+	default 0x11008000 if DEBUG_MTK6589_UART2
+	default 0x11009000 if DEBUG_MTK6589_UART3
 	default 0xe0000000 if ARCH_SPEAR13XX
 	default 0xf0000be0 if ARCH_EBSA110
 	default 0xf1012000 if DEBUG_MVEBU_UART_ALTERNATE
@@ -1058,7 +1099,7 @@ config DEBUG_UART_PHYS
 	default 0xfffff700 if ARCH_IOP33X
 	depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
 		DEBUG_LL_UART_EFM32 || \
-		DEBUG_UART_8250 || DEBUG_UART_PL01X
+		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_UART_MEDIATEK
 
 config DEBUG_UART_VIRT
 	hex "Virtual base address of debug UART"
@@ -1087,6 +1128,10 @@ config DEBUG_UART_VIRT
 	default 0xfe012000 if ARCH_ORION5X
 	default 0xfe017000 if DEBUG_MMP_UART2
 	default 0xfe018000 if DEBUG_MMP_UART3
+	default 0xF1006000 if DEBUG_MTK6589_UART0
+	default 0xF1007000 if DEBUG_MTK6589_UART1
+	default 0xF1008000 if DEBUG_MTK6589_UART2
+	default 0xF1009000 if DEBUG_MTK6589_UART3
 	default 0xfe100000 if DEBUG_IMX23_UART || DEBUG_IMX28_UART
 	default 0xfe230000 if DEBUG_PICOXCELL_UART
 	default 0xfe300000 if DEBUG_BCM_KONA_UART
@@ -1116,7 +1161,7 @@ config DEBUG_UART_VIRT
 	default 0xff003000 if DEBUG_U300_UART
 	default DEBUG_UART_PHYS if !MMU
 	depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
-		DEBUG_UART_8250 || DEBUG_UART_PL01X
+		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_UART_MEDIATEK
 
 config DEBUG_UART_8250_SHIFT
 	int "Register offset shift for the 8250 debug UART"
diff --git a/arch/arm/include/debug/mediatek.S b/arch/arm/include/debug/mediatek.S
new file mode 100644
index 0000000..98e8414
--- /dev/null
+++ b/arch/arm/include/debug/mediatek.S
@@ -0,0 +1,38 @@
+/*
+ * Low-level debug macro for Mediatek SoCs
+ *
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <linux/serial_reg.h>
+
+	        .macro  addruart, rp, rv, tmp
+	        ldr	\rp, =CONFIG_DEBUG_UART_PHYS
+	        ldr	\rv, =CONFIG_DEBUG_UART_VIRT
+	        .endm
+
+	        .macro  senduart,rd,rx
+	        strb    \rd, [\rx, #0x0]
+	        .endm
+
+	        .macro  waituart,rd,rx
+1001:   	ldr \rd, [\rx, #0x14]
+	        tst \rd, #0x40
+	        beq 1001b
+	        .endm
+
+		.macro  busyuart,rd,rx
+1002:   	ldr \rd, [\rx, #0x14]
+	        tst \rd, #0x40
+	        beq 1002b
+	        .endm
-- 
1.7.9.5


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

* [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589
@ 2014-04-09 19:45   ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-09 19:45 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
 arch/arm/Kconfig.debug            |   49 +++++++++++++++++++++++++++++++++++--
 arch/arm/include/debug/mediatek.S |   38 ++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/include/debug/mediatek.S

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 4a2fc0b..dc51495 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -797,6 +797,38 @@ choice
 		  Say Y here if you want kernel low-level debugging support
 		  on Ux500 based platforms.
 
+	config DEBUG_MTK6589_UART0
+		depends on ARCH_MEDIATEK
+		bool "Mediatek mt6589 UART0"
+		select DEBUG_UART_MEDIATEK
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Mediatek mt6589 based platforms.
+
+	config DEBUG_MTK6589_UART1
+		depends on ARCH_MEDIATEK
+		bool "Mediatek mt6589 UART1"
+		select DEBUG_UART_MEDIATEK
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Mediatek mt6589 based platforms.
+
+	config DEBUG_MTK6589_UART2
+		depends on ARCH_MEDIATEK
+		bool "Mediatek mt6589 UART2"
+		select DEBUG_UART_MEDIATEK
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Mediatek mt6589 based platforms.
+
+	config DEBUG_MTK6589_UART3
+		depends on ARCH_MEDIATEK
+		bool "Mediatek mt6589 UART3"
+		select DEBUG_UART_MEDIATEK
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on Mediatek mt6589 based platforms.
+
 	config DEBUG_VEXPRESS_UART0_DETECT
 		bool "Autodetect UART0 on Versatile Express Cortex-A core tiles"
 		depends on ARCH_VEXPRESS && CPU_CP15_MMU
@@ -954,6 +986,10 @@ config DEBUG_MSM_UART
 	bool
 	depends on ARCH_MSM || ARCH_QCOM
 
+config DEBUG_UART_MEDIATEK
+	bool
+	depends on ARCH_MEDIATEK
+
 config DEBUG_LL_INCLUDE
 	string
 	default "debug/8250.S" if DEBUG_LL_UART_8250 || DEBUG_UART_8250
@@ -971,6 +1007,7 @@ config DEBUG_LL_INCLUDE
 				 DEBUG_IMX53_UART ||\
 				 DEBUG_IMX6Q_UART || \
 				 DEBUG_IMX6SL_UART
+	default "debug/mediatek.S" if DEBUG_UART_MEDIATEK
 	default "debug/msm.S" if DEBUG_MSM_UART
 	default "debug/omap2plus.S" if DEBUG_OMAP2PLUS_UART
 	default "debug/sirf.S" if DEBUG_SIRFPRIMA2_UART1 || DEBUG_SIRFMARCO_UART1
@@ -1043,6 +1080,10 @@ config DEBUG_UART_PHYS
 	default 0xd0012000 if DEBUG_MVEBU_UART
 	default 0xd4017000 if DEBUG_MMP_UART2
 	default 0xd4018000 if DEBUG_MMP_UART3
+	default 0x11006000 if DEBUG_MTK6589_UART0
+	default 0x11007000 if DEBUG_MTK6589_UART1
+	default 0x11008000 if DEBUG_MTK6589_UART2
+	default 0x11009000 if DEBUG_MTK6589_UART3
 	default 0xe0000000 if ARCH_SPEAR13XX
 	default 0xf0000be0 if ARCH_EBSA110
 	default 0xf1012000 if DEBUG_MVEBU_UART_ALTERNATE
@@ -1058,7 +1099,7 @@ config DEBUG_UART_PHYS
 	default 0xfffff700 if ARCH_IOP33X
 	depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
 		DEBUG_LL_UART_EFM32 || \
-		DEBUG_UART_8250 || DEBUG_UART_PL01X
+		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_UART_MEDIATEK
 
 config DEBUG_UART_VIRT
 	hex "Virtual base address of debug UART"
@@ -1087,6 +1128,10 @@ config DEBUG_UART_VIRT
 	default 0xfe012000 if ARCH_ORION5X
 	default 0xfe017000 if DEBUG_MMP_UART2
 	default 0xfe018000 if DEBUG_MMP_UART3
+	default 0xF1006000 if DEBUG_MTK6589_UART0
+	default 0xF1007000 if DEBUG_MTK6589_UART1
+	default 0xF1008000 if DEBUG_MTK6589_UART2
+	default 0xF1009000 if DEBUG_MTK6589_UART3
 	default 0xfe100000 if DEBUG_IMX23_UART || DEBUG_IMX28_UART
 	default 0xfe230000 if DEBUG_PICOXCELL_UART
 	default 0xfe300000 if DEBUG_BCM_KONA_UART
@@ -1116,7 +1161,7 @@ config DEBUG_UART_VIRT
 	default 0xff003000 if DEBUG_U300_UART
 	default DEBUG_UART_PHYS if !MMU
 	depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
-		DEBUG_UART_8250 || DEBUG_UART_PL01X
+		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_UART_MEDIATEK
 
 config DEBUG_UART_8250_SHIFT
 	int "Register offset shift for the 8250 debug UART"
diff --git a/arch/arm/include/debug/mediatek.S b/arch/arm/include/debug/mediatek.S
new file mode 100644
index 0000000..98e8414
--- /dev/null
+++ b/arch/arm/include/debug/mediatek.S
@@ -0,0 +1,38 @@
+/*
+ * Low-level debug macro for Mediatek SoCs
+ *
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <linux/serial_reg.h>
+
+	        .macro  addruart, rp, rv, tmp
+	        ldr	\rp, =CONFIG_DEBUG_UART_PHYS
+	        ldr	\rv, =CONFIG_DEBUG_UART_VIRT
+	        .endm
+
+	        .macro  senduart,rd,rx
+	        strb    \rd, [\rx, #0x0]
+	        .endm
+
+	        .macro  waituart,rd,rx
+1001:   	ldr \rd, [\rx, #0x14]
+	        tst \rd, #0x40
+	        beq 1001b
+	        .endm
+
+		.macro  busyuart,rd,rx
+1002:   	ldr \rd, [\rx, #0x14]
+	        tst \rd, #0x40
+	        beq 1002b
+	        .endm
-- 
1.7.9.5

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-09 19:45   ` Matthias Brugger
@ 2014-04-09 20:26     ` Gregory CLEMENT
  -1 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-09 20:26 UTC (permalink / raw)
  To: Matthias Brugger, linux-kernel
  Cc: mark.rutland, andrew, linux-doc, thierry.reding, heiko.stuebner,
	linux, daniel.lezcano, florian.vaussard, sebastian.hesselbarth,
	devicetree, jason, pawel.moll, ijc+devicetree, robh+dt, tglx,
	linux-arm-kernel, rdunlap, silvio.fricke, galak, olof, jic23

Hi Matthias,

On 09/04/2014 19:45, Matthias Brugger wrote:
> This adds a generic devicetree board file and a dtsi for boards
> based on the MT6589 SoCs from Mediatek.
> 
> Apart from the generic parts (gic, clocks) the only component
> currently supported are the timers.
> 
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>  arch/arm/Kconfig                                   |    2 +
>  arch/arm/Makefile                                  |    1 +
>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++
>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>  arch/arm/mach-mediatek/Makefile                    |    1 +
>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>  7 files changed, 164 insertions(+)
>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>  create mode 100644 arch/arm/mach-mediatek/Makefile
>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
> 
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index 0f01c9b..af48801 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -67,6 +67,7 @@ linux	Linux-specific binding
>  lsi	LSI Corp. (LSI Logic)
>  marvell	Marvell Technology Group Ltd.
>  maxim	Maxim Integrated Products
> +mediatek	MediaTek Inc.
>  microchip	Microchip Technology Inc.
>  mosaixtech	Mosaix Technologies, Inc.
>  moxa	Moxa
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 5db05f6a..04d46ec 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>  
>  source "arch/arm/mach-imx/Kconfig"
>  
> +source "arch/arm/mach-mediatek/Kconfig"
> +
>  source "arch/arm/mach-mxs/Kconfig"
>  
>  source "arch/arm/mach-netx/Kconfig"
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 41c1931..8ce9774 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)		+= msm
>  machine-$(CONFIG_ARCH_MV78XX0)		+= mv78xx0
>  machine-$(CONFIG_ARCH_MVEBU)		+= mvebu
>  machine-$(CONFIG_ARCH_MXC)		+= imx
> +machine-$(CONFIG_ARCH_MEDIATEK)		+= mediatek
>  machine-$(CONFIG_ARCH_MXS)		+= mxs
>  machine-$(CONFIG_ARCH_NETX)		+= netx
>  machine-$(CONFIG_ARCH_NOMADIK)		+= nomadik
> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
> new file mode 100644
> index 0000000..6dbb74f
> --- /dev/null
> +++ b/arch/arm/boot/dts/mtk6589.dtsi
> @@ -0,0 +1,105 @@
> +/*
> + * Copyright (c) 2014 MundoReader S.L.
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <dt-bindings/interrupt-controller/irq.h>
> +#include <dt-bindings/interrupt-controller/arm-gic.h>
> +#include "skeleton.dtsi"
> +
> +/ {
> +	compatible = "mediatek,mt6589";
> +	interrupt-parent = <&gic>;
> +
> +	cpus {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		cpu@0 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a7";
> +			next-level-cache = <&L2>;
> +			reg = <0x0>;
> +		};
> +		cpu@1 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a7";
> +			next-level-cache = <&L2>;
> +			reg = <0x1>;
> +		};
> +		cpu@2 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a7";
> +			next-level-cache = <&L2>;
> +			reg = <0x2>;
> +		};
> +		cpu@3 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a7";
> +			next-level-cache = <&L2>;
> +			reg = <0x3>;
> +		};
> +
> +	};
> +
> +	clocks {
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		ranges;
> +
> +		system_clk: system_clk {
> +			compatible = "fixed-clock";
> +			clock-frequency = <13000000>;
> +			#clock-cells = <0>;
> +			clock-output-names = "system_clk";
> +		};

Is it really a fixed clock without any parent, or do you
declare it as a fixed clock because you don't have any clock
common framework support yet?

> +
> +		rtc_clk: rtc_clk {
> +			compatible = "fixed-clock";
> +			clock-frequency = <32000>;
> +			#clock-cells = <0>;
> +			clock-output-names = "rtc_clk";
> +		};
> +	};
> +
> +	soc {
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		compatible = "simple-bus";
> +		clock-ranges;
> +		ranges;
> +
> +		gic: interrupt-controller@10212000 {
> +			compatible = "arm,cortex-a9-gic";
> +			interrupt-controller;
> +			#interrupt-cells = <3>;
> +			reg = <0x10211000 0x1000>,
> +			      <0x10212000 0x1000>;
> +		};
> +
> +		L2: l2-cache-controller@1020e000 {
> +			compatible = "arm,pl310-cache";
> +			reg = <0x1020e000 0x1000>;
> +			cache-unified;
> +			cache-level = <2>;
> +		};
> +
> +		timer: timer@10008000 {
> +			compatible = "mediatek,mtk6589-timer";
> +			reg = <0x10008000 0x80>;
> +			interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
> +			clocks = <&system_clk>, <&rtc_clk>;
> +			clock-names = "sys_clk", "rtc_clk";
> +		};
> +	};
> +};
> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> new file mode 100644
> index 0000000..c0139ca
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/Kconfig
> @@ -0,0 +1,14 @@
> +config ARCH_MEDIATEK
> +	bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
> +	select ARCH_REQUIRE_GPIOLIB
> +	select ARM_GIC
> +	select CACHE_L2X0
> +	select HAVE_ARM_TWD if LOCAL_TIMERS

LOCAL_TIMERS no longer exist

> +	select HAVE_SMP
> +	select LOCAL_TIMERS if SMP
ditto

so what about this instead:

	select HAVE_ARM_TWD if SMP


The rest of this patch looks good.

Thanks,

Gregory

> +	select COMMON_CLK
> +	select GENERIC_CLOCKEVENTS
> +	select MTK_TIMER
> +	select CLKSRC_MMIO
> +	help
> +	  Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
> diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
> new file mode 100644
> index 0000000..43e619f
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/Makefile
> @@ -0,0 +1 @@
> +obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
> diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
> new file mode 100644
> index 0000000..f630403
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/mediatek.c
> @@ -0,0 +1,40 @@
> +/*
> + * Device Tree support for Mediatek SoCs
> + *
> + * Copyright (c) 2014 MundoReader S.L.
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/of_platform.h>
> +#include <linux/irqchip.h>
> +#include <asm/mach/arch.h>
> +#include <asm/mach/map.h>
> +#include <asm/hardware/cache-l2x0.h>
> +
> +static void __init mediatek_dt_init(void)
> +{
> +	l2x0_of_init(0, ~0);
> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +}
> +
> +static const char * const mediatek_board_dt_compat[] = {
> +	"mediatek,mt6589",
> +	NULL,
> +};
> +
> +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
> +	.init_machine	= mediatek_dt_init,
> +	.dt_compat	= mediatek_board_dt_compat,
> +MACHINE_END
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-09 20:26     ` Gregory CLEMENT
  0 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-09 20:26 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Matthias,

On 09/04/2014 19:45, Matthias Brugger wrote:
> This adds a generic devicetree board file and a dtsi for boards
> based on the MT6589 SoCs from Mediatek.
> 
> Apart from the generic parts (gic, clocks) the only component
> currently supported are the timers.
> 
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>  arch/arm/Kconfig                                   |    2 +
>  arch/arm/Makefile                                  |    1 +
>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++
>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>  arch/arm/mach-mediatek/Makefile                    |    1 +
>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>  7 files changed, 164 insertions(+)
>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>  create mode 100644 arch/arm/mach-mediatek/Makefile
>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
> 
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index 0f01c9b..af48801 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -67,6 +67,7 @@ linux	Linux-specific binding
>  lsi	LSI Corp. (LSI Logic)
>  marvell	Marvell Technology Group Ltd.
>  maxim	Maxim Integrated Products
> +mediatek	MediaTek Inc.
>  microchip	Microchip Technology Inc.
>  mosaixtech	Mosaix Technologies, Inc.
>  moxa	Moxa
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 5db05f6a..04d46ec 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>  
>  source "arch/arm/mach-imx/Kconfig"
>  
> +source "arch/arm/mach-mediatek/Kconfig"
> +
>  source "arch/arm/mach-mxs/Kconfig"
>  
>  source "arch/arm/mach-netx/Kconfig"
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 41c1931..8ce9774 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)		+= msm
>  machine-$(CONFIG_ARCH_MV78XX0)		+= mv78xx0
>  machine-$(CONFIG_ARCH_MVEBU)		+= mvebu
>  machine-$(CONFIG_ARCH_MXC)		+= imx
> +machine-$(CONFIG_ARCH_MEDIATEK)		+= mediatek
>  machine-$(CONFIG_ARCH_MXS)		+= mxs
>  machine-$(CONFIG_ARCH_NETX)		+= netx
>  machine-$(CONFIG_ARCH_NOMADIK)		+= nomadik
> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
> new file mode 100644
> index 0000000..6dbb74f
> --- /dev/null
> +++ b/arch/arm/boot/dts/mtk6589.dtsi
> @@ -0,0 +1,105 @@
> +/*
> + * Copyright (c) 2014 MundoReader S.L.
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <dt-bindings/interrupt-controller/irq.h>
> +#include <dt-bindings/interrupt-controller/arm-gic.h>
> +#include "skeleton.dtsi"
> +
> +/ {
> +	compatible = "mediatek,mt6589";
> +	interrupt-parent = <&gic>;
> +
> +	cpus {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		cpu at 0 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a7";
> +			next-level-cache = <&L2>;
> +			reg = <0x0>;
> +		};
> +		cpu at 1 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a7";
> +			next-level-cache = <&L2>;
> +			reg = <0x1>;
> +		};
> +		cpu at 2 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a7";
> +			next-level-cache = <&L2>;
> +			reg = <0x2>;
> +		};
> +		cpu at 3 {
> +			device_type = "cpu";
> +			compatible = "arm,cortex-a7";
> +			next-level-cache = <&L2>;
> +			reg = <0x3>;
> +		};
> +
> +	};
> +
> +	clocks {
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		ranges;
> +
> +		system_clk: system_clk {
> +			compatible = "fixed-clock";
> +			clock-frequency = <13000000>;
> +			#clock-cells = <0>;
> +			clock-output-names = "system_clk";
> +		};

Is it really a fixed clock without any parent, or do you
declare it as a fixed clock because you don't have any clock
common framework support yet?

> +
> +		rtc_clk: rtc_clk {
> +			compatible = "fixed-clock";
> +			clock-frequency = <32000>;
> +			#clock-cells = <0>;
> +			clock-output-names = "rtc_clk";
> +		};
> +	};
> +
> +	soc {
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		compatible = "simple-bus";
> +		clock-ranges;
> +		ranges;
> +
> +		gic: interrupt-controller at 10212000 {
> +			compatible = "arm,cortex-a9-gic";
> +			interrupt-controller;
> +			#interrupt-cells = <3>;
> +			reg = <0x10211000 0x1000>,
> +			      <0x10212000 0x1000>;
> +		};
> +
> +		L2: l2-cache-controller at 1020e000 {
> +			compatible = "arm,pl310-cache";
> +			reg = <0x1020e000 0x1000>;
> +			cache-unified;
> +			cache-level = <2>;
> +		};
> +
> +		timer: timer at 10008000 {
> +			compatible = "mediatek,mtk6589-timer";
> +			reg = <0x10008000 0x80>;
> +			interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
> +			clocks = <&system_clk>, <&rtc_clk>;
> +			clock-names = "sys_clk", "rtc_clk";
> +		};
> +	};
> +};
> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> new file mode 100644
> index 0000000..c0139ca
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/Kconfig
> @@ -0,0 +1,14 @@
> +config ARCH_MEDIATEK
> +	bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
> +	select ARCH_REQUIRE_GPIOLIB
> +	select ARM_GIC
> +	select CACHE_L2X0
> +	select HAVE_ARM_TWD if LOCAL_TIMERS

LOCAL_TIMERS no longer exist

> +	select HAVE_SMP
> +	select LOCAL_TIMERS if SMP
ditto

so what about this instead:

	select HAVE_ARM_TWD if SMP


The rest of this patch looks good.

Thanks,

Gregory

> +	select COMMON_CLK
> +	select GENERIC_CLOCKEVENTS
> +	select MTK_TIMER
> +	select CLKSRC_MMIO
> +	help
> +	  Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
> diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
> new file mode 100644
> index 0000000..43e619f
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/Makefile
> @@ -0,0 +1 @@
> +obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
> diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
> new file mode 100644
> index 0000000..f630403
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/mediatek.c
> @@ -0,0 +1,40 @@
> +/*
> + * Device Tree support for Mediatek SoCs
> + *
> + * Copyright (c) 2014 MundoReader S.L.
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/of_platform.h>
> +#include <linux/irqchip.h>
> +#include <asm/mach/arch.h>
> +#include <asm/mach/map.h>
> +#include <asm/hardware/cache-l2x0.h>
> +
> +static void __init mediatek_dt_init(void)
> +{
> +	l2x0_of_init(0, ~0);
> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +}
> +
> +static const char * const mediatek_board_dt_compat[] = {
> +	"mediatek,mt6589",
> +	NULL,
> +};
> +
> +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
> +	.init_machine	= mediatek_dt_init,
> +	.dt_compat	= mediatek_board_dt_compat,
> +MACHINE_END
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589
  2014-04-09 19:45   ` Matthias Brugger
@ 2014-04-09 20:54     ` Gregory CLEMENT
  -1 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-09 20:54 UTC (permalink / raw)
  To: Matthias Brugger, linux-kernel
  Cc: mark.rutland, andrew, linux-doc, thierry.reding, heiko.stuebner,
	linux, daniel.lezcano, florian.vaussard, sebastian.hesselbarth,
	devicetree, jason, pawel.moll, ijc+devicetree, robh+dt, tglx,
	linux-arm-kernel, rdunlap, silvio.fricke, galak, olof, jic23

Hi Matthias,

On 09/04/2014 19:45, Matthias Brugger wrote:
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  arch/arm/Kconfig.debug            |   49 +++++++++++++++++++++++++++++++++++--
>  arch/arm/include/debug/mediatek.S |   38 ++++++++++++++++++++++++++++
>  2 files changed, 85 insertions(+), 2 deletions(-)
>  create mode 100644 arch/arm/include/debug/mediatek.S
> 
> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
> index 4a2fc0b..dc51495 100644
> --- a/arch/arm/Kconfig.debug
> +++ b/arch/arm/Kconfig.debug
> @@ -797,6 +797,38 @@ choice
>  		  Say Y here if you want kernel low-level debugging support
>  		  on Ux500 based platforms.
>  
> +	config DEBUG_MTK6589_UART0
> +		depends on ARCH_MEDIATEK
> +		bool "Mediatek mt6589 UART0"
> +		select DEBUG_UART_MEDIATEK
> +		help
> +		  Say Y here if you want kernel low-level debugging support
> +		  on Mediatek mt6589 based platforms.
> +
> +	config DEBUG_MTK6589_UART1
> +		depends on ARCH_MEDIATEK
> +		bool "Mediatek mt6589 UART1"
> +		select DEBUG_UART_MEDIATEK
> +		help
> +		  Say Y here if you want kernel low-level debugging support
> +		  on Mediatek mt6589 based platforms.
> +
> +	config DEBUG_MTK6589_UART2
> +		depends on ARCH_MEDIATEK
> +		bool "Mediatek mt6589 UART2"
> +		select DEBUG_UART_MEDIATEK
> +		help
> +		  Say Y here if you want kernel low-level debugging support
> +		  on Mediatek mt6589 based platforms.
> +
> +	config DEBUG_MTK6589_UART3
> +		depends on ARCH_MEDIATEK
> +		bool "Mediatek mt6589 UART3"
> +		select DEBUG_UART_MEDIATEK
> +		help
> +		  Say Y here if you want kernel low-level debugging support
> +		  on Mediatek mt6589 based platforms.
> +
>  	config DEBUG_VEXPRESS_UART0_DETECT
>  		bool "Autodetect UART0 on Versatile Express Cortex-A core tiles"
>  		depends on ARCH_VEXPRESS && CPU_CP15_MMU
> @@ -954,6 +986,10 @@ config DEBUG_MSM_UART
>  	bool
>  	depends on ARCH_MSM || ARCH_QCOM
>  
> +config DEBUG_UART_MEDIATEK
> +	bool
> +	depends on ARCH_MEDIATEK
> +
>  config DEBUG_LL_INCLUDE
>  	string
>  	default "debug/8250.S" if DEBUG_LL_UART_8250 || DEBUG_UART_8250
> @@ -971,6 +1007,7 @@ config DEBUG_LL_INCLUDE
>  				 DEBUG_IMX53_UART ||\
>  				 DEBUG_IMX6Q_UART || \
>  				 DEBUG_IMX6SL_UART
> +	default "debug/mediatek.S" if DEBUG_UART_MEDIATEK
>  	default "debug/msm.S" if DEBUG_MSM_UART
>  	default "debug/omap2plus.S" if DEBUG_OMAP2PLUS_UART
>  	default "debug/sirf.S" if DEBUG_SIRFPRIMA2_UART1 || DEBUG_SIRFMARCO_UART1
> @@ -1043,6 +1080,10 @@ config DEBUG_UART_PHYS
>  	default 0xd0012000 if DEBUG_MVEBU_UART
>  	default 0xd4017000 if DEBUG_MMP_UART2
>  	default 0xd4018000 if DEBUG_MMP_UART3

it seems that this symbol are sorted by address so your symbols
should go just after the line
default 0x101fb000 if DEBUG_NOMADIK_UART

> +	default 0x11006000 if DEBUG_MTK6589_UART0
> +	default 0x11007000 if DEBUG_MTK6589_UART1
> +	default 0x11008000 if DEBUG_MTK6589_UART2
> +	default 0x11009000 if DEBUG_MTK6589_UART3
>  	default 0xe0000000 if ARCH_SPEAR13XX
>  	default 0xf0000be0 if ARCH_EBSA110
>  	default 0xf1012000 if DEBUG_MVEBU_UART_ALTERNATE
> @@ -1058,7 +1099,7 @@ config DEBUG_UART_PHYS
>  	default 0xfffff700 if ARCH_IOP33X
>  	depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
>  		DEBUG_LL_UART_EFM32 || \
> -		DEBUG_UART_8250 || DEBUG_UART_PL01X
> +		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_UART_MEDIATEK
>  
>  config DEBUG_UART_VIRT
>  	hex "Virtual base address of debug UART"
> @@ -1087,6 +1128,10 @@ config DEBUG_UART_VIRT
>  	default 0xfe012000 if ARCH_ORION5X
>  	default 0xfe017000 if DEBUG_MMP_UART2
>  	default 0xfe018000 if DEBUG_MMP_UART3
> +	default 0xF1006000 if DEBUG_MTK6589_UART0
> +	default 0xF1007000 if DEBUG_MTK6589_UART1
> +	default 0xF1008000 if DEBUG_MTK6589_UART2
> +	default 0xF1009000 if DEBUG_MTK6589_UART3
>  	default 0xfe100000 if DEBUG_IMX23_UART || DEBUG_IMX28_UART
>  	default 0xfe230000 if DEBUG_PICOXCELL_UART
>  	default 0xfe300000 if DEBUG_BCM_KONA_UART
> @@ -1116,7 +1161,7 @@ config DEBUG_UART_VIRT
>  	default 0xff003000 if DEBUG_U300_UART
>  	default DEBUG_UART_PHYS if !MMU
>  	depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
> -		DEBUG_UART_8250 || DEBUG_UART_PL01X
> +		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_UART_MEDIATEK
>  
>  config DEBUG_UART_8250_SHIFT
>  	int "Register offset shift for the 8250 debug UART"
> diff --git a/arch/arm/include/debug/mediatek.S b/arch/arm/include/debug/mediatek.S
> new file mode 100644
> index 0000000..98e8414
> --- /dev/null
> +++ b/arch/arm/include/debug/mediatek.S
> @@ -0,0 +1,38 @@
> +/*
> + * Low-level debug macro for Mediatek SoCs
> + *
> + * Copyright (c) 2014 MundoReader S.L.
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +#include <linux/serial_reg.h>
> +
> +	        .macro  addruart, rp, rv, tmp
> +	        ldr	\rp, =CONFIG_DEBUG_UART_PHYS
> +	        ldr	\rv, =CONFIG_DEBUG_UART_VIRT
> +	        .endm
> +
> +	        .macro  senduart,rd,rx
> +	        strb    \rd, [\rx, #0x0]
What about using a #define instead of numerical value?

> +	        .endm
> +
> +	        .macro  waituart,rd,rx
> +1001:   	ldr \rd, [\rx, #0x14]
ditto
> +	        tst \rd, #0x40
ditto
> +	        beq 1001b
> +	        .endm
> +
> +		.macro  busyuart,rd,rx
> +1002:   	ldr \rd, [\rx, #0x14]
ditto
> +	        tst \rd, #0x40
ditto
> +	        beq 1002b
> +	        .endm
> 

This file looks very similar to arch/arm/include/debug/pl01x.S,
the only difference is the value of some register offsets.
Should it be possible to make it configurable and then use the
same file?


Thanks,

Gregory



-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589
@ 2014-04-09 20:54     ` Gregory CLEMENT
  0 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-09 20:54 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Matthias,

On 09/04/2014 19:45, Matthias Brugger wrote:
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  arch/arm/Kconfig.debug            |   49 +++++++++++++++++++++++++++++++++++--
>  arch/arm/include/debug/mediatek.S |   38 ++++++++++++++++++++++++++++
>  2 files changed, 85 insertions(+), 2 deletions(-)
>  create mode 100644 arch/arm/include/debug/mediatek.S
> 
> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
> index 4a2fc0b..dc51495 100644
> --- a/arch/arm/Kconfig.debug
> +++ b/arch/arm/Kconfig.debug
> @@ -797,6 +797,38 @@ choice
>  		  Say Y here if you want kernel low-level debugging support
>  		  on Ux500 based platforms.
>  
> +	config DEBUG_MTK6589_UART0
> +		depends on ARCH_MEDIATEK
> +		bool "Mediatek mt6589 UART0"
> +		select DEBUG_UART_MEDIATEK
> +		help
> +		  Say Y here if you want kernel low-level debugging support
> +		  on Mediatek mt6589 based platforms.
> +
> +	config DEBUG_MTK6589_UART1
> +		depends on ARCH_MEDIATEK
> +		bool "Mediatek mt6589 UART1"
> +		select DEBUG_UART_MEDIATEK
> +		help
> +		  Say Y here if you want kernel low-level debugging support
> +		  on Mediatek mt6589 based platforms.
> +
> +	config DEBUG_MTK6589_UART2
> +		depends on ARCH_MEDIATEK
> +		bool "Mediatek mt6589 UART2"
> +		select DEBUG_UART_MEDIATEK
> +		help
> +		  Say Y here if you want kernel low-level debugging support
> +		  on Mediatek mt6589 based platforms.
> +
> +	config DEBUG_MTK6589_UART3
> +		depends on ARCH_MEDIATEK
> +		bool "Mediatek mt6589 UART3"
> +		select DEBUG_UART_MEDIATEK
> +		help
> +		  Say Y here if you want kernel low-level debugging support
> +		  on Mediatek mt6589 based platforms.
> +
>  	config DEBUG_VEXPRESS_UART0_DETECT
>  		bool "Autodetect UART0 on Versatile Express Cortex-A core tiles"
>  		depends on ARCH_VEXPRESS && CPU_CP15_MMU
> @@ -954,6 +986,10 @@ config DEBUG_MSM_UART
>  	bool
>  	depends on ARCH_MSM || ARCH_QCOM
>  
> +config DEBUG_UART_MEDIATEK
> +	bool
> +	depends on ARCH_MEDIATEK
> +
>  config DEBUG_LL_INCLUDE
>  	string
>  	default "debug/8250.S" if DEBUG_LL_UART_8250 || DEBUG_UART_8250
> @@ -971,6 +1007,7 @@ config DEBUG_LL_INCLUDE
>  				 DEBUG_IMX53_UART ||\
>  				 DEBUG_IMX6Q_UART || \
>  				 DEBUG_IMX6SL_UART
> +	default "debug/mediatek.S" if DEBUG_UART_MEDIATEK
>  	default "debug/msm.S" if DEBUG_MSM_UART
>  	default "debug/omap2plus.S" if DEBUG_OMAP2PLUS_UART
>  	default "debug/sirf.S" if DEBUG_SIRFPRIMA2_UART1 || DEBUG_SIRFMARCO_UART1
> @@ -1043,6 +1080,10 @@ config DEBUG_UART_PHYS
>  	default 0xd0012000 if DEBUG_MVEBU_UART
>  	default 0xd4017000 if DEBUG_MMP_UART2
>  	default 0xd4018000 if DEBUG_MMP_UART3

it seems that this symbol are sorted by address so your symbols
should go just after the line
default 0x101fb000 if DEBUG_NOMADIK_UART

> +	default 0x11006000 if DEBUG_MTK6589_UART0
> +	default 0x11007000 if DEBUG_MTK6589_UART1
> +	default 0x11008000 if DEBUG_MTK6589_UART2
> +	default 0x11009000 if DEBUG_MTK6589_UART3
>  	default 0xe0000000 if ARCH_SPEAR13XX
>  	default 0xf0000be0 if ARCH_EBSA110
>  	default 0xf1012000 if DEBUG_MVEBU_UART_ALTERNATE
> @@ -1058,7 +1099,7 @@ config DEBUG_UART_PHYS
>  	default 0xfffff700 if ARCH_IOP33X
>  	depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
>  		DEBUG_LL_UART_EFM32 || \
> -		DEBUG_UART_8250 || DEBUG_UART_PL01X
> +		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_UART_MEDIATEK
>  
>  config DEBUG_UART_VIRT
>  	hex "Virtual base address of debug UART"
> @@ -1087,6 +1128,10 @@ config DEBUG_UART_VIRT
>  	default 0xfe012000 if ARCH_ORION5X
>  	default 0xfe017000 if DEBUG_MMP_UART2
>  	default 0xfe018000 if DEBUG_MMP_UART3
> +	default 0xF1006000 if DEBUG_MTK6589_UART0
> +	default 0xF1007000 if DEBUG_MTK6589_UART1
> +	default 0xF1008000 if DEBUG_MTK6589_UART2
> +	default 0xF1009000 if DEBUG_MTK6589_UART3
>  	default 0xfe100000 if DEBUG_IMX23_UART || DEBUG_IMX28_UART
>  	default 0xfe230000 if DEBUG_PICOXCELL_UART
>  	default 0xfe300000 if DEBUG_BCM_KONA_UART
> @@ -1116,7 +1161,7 @@ config DEBUG_UART_VIRT
>  	default 0xff003000 if DEBUG_U300_UART
>  	default DEBUG_UART_PHYS if !MMU
>  	depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
> -		DEBUG_UART_8250 || DEBUG_UART_PL01X
> +		DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_UART_MEDIATEK
>  
>  config DEBUG_UART_8250_SHIFT
>  	int "Register offset shift for the 8250 debug UART"
> diff --git a/arch/arm/include/debug/mediatek.S b/arch/arm/include/debug/mediatek.S
> new file mode 100644
> index 0000000..98e8414
> --- /dev/null
> +++ b/arch/arm/include/debug/mediatek.S
> @@ -0,0 +1,38 @@
> +/*
> + * Low-level debug macro for Mediatek SoCs
> + *
> + * Copyright (c) 2014 MundoReader S.L.
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +#include <linux/serial_reg.h>
> +
> +	        .macro  addruart, rp, rv, tmp
> +	        ldr	\rp, =CONFIG_DEBUG_UART_PHYS
> +	        ldr	\rv, =CONFIG_DEBUG_UART_VIRT
> +	        .endm
> +
> +	        .macro  senduart,rd,rx
> +	        strb    \rd, [\rx, #0x0]
What about using a #define instead of numerical value?

> +	        .endm
> +
> +	        .macro  waituart,rd,rx
> +1001:   	ldr \rd, [\rx, #0x14]
ditto
> +	        tst \rd, #0x40
ditto
> +	        beq 1001b
> +	        .endm
> +
> +		.macro  busyuart,rd,rx
> +1002:   	ldr \rd, [\rx, #0x14]
ditto
> +	        tst \rd, #0x40
ditto
> +	        beq 1002b
> +	        .endm
> 

This file looks very similar to arch/arm/include/debug/pl01x.S,
the only difference is the value of some register offsets.
Should it be possible to make it configurable and then use the
same file?


Thanks,

Gregory



-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [PATCH 2/4] dt-bindings: add mtk-timer bindings
  2014-04-09 19:45   ` Matthias Brugger
@ 2014-04-09 20:56     ` Gregory CLEMENT
  -1 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-09 20:56 UTC (permalink / raw)
  To: Matthias Brugger, linux-kernel
  Cc: mark.rutland, andrew, linux-doc, thierry.reding, heiko.stuebner,
	linux, daniel.lezcano, florian.vaussard, sebastian.hesselbarth,
	devicetree, jason, pawel.moll, ijc+devicetree, robh+dt, tglx,
	linux-arm-kernel, rdunlap, silvio.fricke, galak, olof, jic23

Hi Matthias,
On 09/04/2014 19:45, Matthias Brugger wrote:
> Add binding documentation for the General Porpose Timer driver of
> the Mediatek SoCs.
> 
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  .../bindings/timer/mediatek,mtk-timer.txt          |   19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
> 
> diff --git a/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
> new file mode 100644
> index 0000000..db3c836
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
> @@ -0,0 +1,19 @@
> +Mediatek MT6598, MT6577 and MT6572 Timers
> +---------------------------------------
> +
> +Required properties:
> +- compatible: Should be "mediatek,mtk6589-timer"
> +- reg: Should contain location and length for timers register.
> +- clock-names : Must include the following entries:
> +  "sysclk" (13 MHz system clock),
> +  "rtcclk" (32 KHz RTC clock).

It would be better to make the clocks mandatory and not their name

Thanks,

Gregory

> +
> +Examples:
> +
> +	timer {
> +		compatible = "mediatek,mtk6589-timer";
> +		reg = <0x10008000 0x80>;
> +		interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
> +		clocks = <&system_clk>, <&rtc-clk>;
> +		clock-names = "sysclk", "rtcclk";
> +	};
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* [PATCH 2/4] dt-bindings: add mtk-timer bindings
@ 2014-04-09 20:56     ` Gregory CLEMENT
  0 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-09 20:56 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Matthias,
On 09/04/2014 19:45, Matthias Brugger wrote:
> Add binding documentation for the General Porpose Timer driver of
> the Mediatek SoCs.
> 
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  .../bindings/timer/mediatek,mtk-timer.txt          |   19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
> 
> diff --git a/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
> new file mode 100644
> index 0000000..db3c836
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
> @@ -0,0 +1,19 @@
> +Mediatek MT6598, MT6577 and MT6572 Timers
> +---------------------------------------
> +
> +Required properties:
> +- compatible: Should be "mediatek,mtk6589-timer"
> +- reg: Should contain location and length for timers register.
> +- clock-names : Must include the following entries:
> +  "sysclk" (13 MHz system clock),
> +  "rtcclk" (32 KHz RTC clock).

It would be better to make the clocks mandatory and not their name

Thanks,

Gregory

> +
> +Examples:
> +
> +	timer {
> +		compatible = "mediatek,mtk6589-timer";
> +		reg = <0x10008000 0x80>;
> +		interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
> +		clocks = <&system_clk>, <&rtc-clk>;
> +		clock-names = "sysclk", "rtcclk";
> +	};
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 20:58     ` Stephen Boyd
  0 siblings, 0 replies; 74+ messages in thread
From: Stephen Boyd @ 2014-04-09 20:58 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: linux-kernel, mark.rutland, andrew, linux-doc, thierry.reding,
	heiko.stuebner, linux, daniel.lezcano, florian.vaussard,
	sebastian.hesselbarth, devicetree, jason, pawel.moll,
	ijc+devicetree, robh+dt, tglx, linux-arm-kernel, rdunlap,
	silvio.fricke, galak, olof, jic23

On 04/09, Matthias Brugger wrote:
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 96918e1..bb29321 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -144,6 +144,10 @@ config VF_PIT_TIMER
>  config SYS_SUPPORTS_SH_CMT
>          bool
>  
> +config MTK_TIMER
> +	bool
> +
> +

Why two newlines?

> diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
> new file mode 100644
> index 0000000..bf901e3
> --- /dev/null
> +++ b/drivers/clocksource/mtk_timer.c
> @@ -0,0 +1,248 @@
> +
> +#include <linux/clk.h>
> +#include <linux/clockchips.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/irqreturn.h>
> +#include <linux/sched_clock.h>

Were you planning on registering a sched_clock source?

> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +
[...]
> +
> +static struct clock_event_device mtk_clockevent = {
> +	.name = "mtk_tick",
> +	.rating = 300,
> +	.shift = 32,

This is unnecessary as it's handled by
clockevents_config_and_register().

> +	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
> +	.set_mode = mtk_clkevt_mode,
> +	.set_next_event = mtk_clkevt_next_event,
> +};
> +
> +
> +static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
> +{
> +	struct clock_event_device *evt = (struct clock_event_device *)dev_id;

Unnecessary cast from void.

> +
> +	/* Acknowledge timer0 irq */
> +	writel(GPT_IRQ_ACK(GPT_CLK_EVT), gpt_base + GPT_IRQ_ACK_REG);
> +	evt->event_handler(evt);
> +
> +	return IRQ_HANDLED;
> +}
> +
[...]
> +
> +static struct irqaction mtk_timer_irq = {
> +	.name = "mtk_timer0",
> +	.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,

IRQF_DISABLED is a nop. Remove it.

> +	.handler = mtk_timer_interrupt,
> +	.dev_id = &mtk_clockevent,
> +};
> +
> +static u32 mtk_timer_sched_read(void)
> +{
> +	return readl(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC));
> +}

This is unused unless you register a sched_clock source.

> +
> +static void __init mtk_timer_init(struct device_node *node)
> +{
> +	unsigned long rate = 0;
> +	struct clk *clk;
> +	int ret, irq;
> +	u32 val;
> +
> +	gpt_base = of_iomap(node, 0);
> +	if (!gpt_base)
> +		panic("Can't map registers");
> +
> +	irq = irq_of_parse_and_map(node, 0);
> +	if (irq <= 0)
> +		panic("Can't parse IRQ");
> +
> +	clk = of_clk_get_by_name(node, "sys_clk");
> +	if (IS_ERR(clk))
> +		panic("Can't get timer clock");
> +	clk_prepare_enable(clk);
> +
> +	rate = clk_get_rate(clk);
> +
> +	mtk_timer_global_reset();
> +
> +	/* Configure clock source */
> +	mtk_timer_reset(GPT_CLK_SRC);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_SRC));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_FREERUN) | TIMER_CTRL_ENABLE,
> +				gpt_base + TIMER_CTRL_REG(GPT_CLK_SRC));
> +
> +	clocksource_mmio_init(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), node->name,
> +			      rate, 300, 32, clocksource_mmio_readl_up);
> +
> +	ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
> +
> +	/* Configure clock event */
> +	mtk_timer_reset(GPT_CLK_EVT);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_EVT));
> +	writel(0, gpt_base + TIMER_CMP_REG(GPT_CLK_EVT));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT) | TIMER_CTRL_ENABLE,
> +			gpt_base + TIMER_CTRL_REG(GPT_CLK_EVT));
> +
> +	ret = setup_irq(irq, &mtk_timer_irq);

Most clocksource drivers use request_irq() nowadays. Can you use
that?

> +	if (ret)
> +		pr_warn("failed to setup irq %d\n", irq);
> +
> +	/* Enable timer0 interrupt */
> +	val = readl(gpt_base + GPT_IRQ_EN_REG);
> +	writel(val | GPT_IRQ_ENABLE(GPT_CLK_EVT), gpt_base + GPT_IRQ_EN_REG);
> +
> +	mtk_clockevent.cpumask = cpumask_of(0);

Is it possible for this timer to be used on SMP hardware? If so,
this should probably be cpu_all_mask. Please assign the .irq
member here as well.

> +
> +	clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
> +					0xffffffff);
> +}
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

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

* Re: [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 20:58     ` Stephen Boyd
  0 siblings, 0 replies; 74+ messages in thread
From: Stephen Boyd @ 2014-04-09 20:58 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, mark.rutland-5wv7dgnIgG8,
	andrew-g2DYL2Zd6BY, linux-doc-u79uwXL29TY76Z2rM5mHXA,
	thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	heiko.stuebner-K3U4GQvHnyU, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A,
	florian.vaussard-p8DiymsW2f8,
	sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-u79uwXL29TY76Z2rM5mHXA, jason-NLaQJdtUoK4Be96aLqz0jA,
	pawel.moll-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, tglx-hfZtesqFncYOwBW4kG4KsQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	rdunlap-wEGCiKHe2LqWVfeAwA7xHQ,
	silvio.fricke-Re5JQEeQqe8AvxtiuMwx3w,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, olof-nZhT3qVonbNeoWH0uzbU5w,
	jic23-DgEjT+Ai2ygdnm+yROfE0A

On 04/09, Matthias Brugger wrote:
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 96918e1..bb29321 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -144,6 +144,10 @@ config VF_PIT_TIMER
>  config SYS_SUPPORTS_SH_CMT
>          bool
>  
> +config MTK_TIMER
> +	bool
> +
> +

Why two newlines?

> diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
> new file mode 100644
> index 0000000..bf901e3
> --- /dev/null
> +++ b/drivers/clocksource/mtk_timer.c
> @@ -0,0 +1,248 @@
> +
> +#include <linux/clk.h>
> +#include <linux/clockchips.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/irqreturn.h>
> +#include <linux/sched_clock.h>

Were you planning on registering a sched_clock source?

> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +
[...]
> +
> +static struct clock_event_device mtk_clockevent = {
> +	.name = "mtk_tick",
> +	.rating = 300,
> +	.shift = 32,

This is unnecessary as it's handled by
clockevents_config_and_register().

> +	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
> +	.set_mode = mtk_clkevt_mode,
> +	.set_next_event = mtk_clkevt_next_event,
> +};
> +
> +
> +static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
> +{
> +	struct clock_event_device *evt = (struct clock_event_device *)dev_id;

Unnecessary cast from void.

> +
> +	/* Acknowledge timer0 irq */
> +	writel(GPT_IRQ_ACK(GPT_CLK_EVT), gpt_base + GPT_IRQ_ACK_REG);
> +	evt->event_handler(evt);
> +
> +	return IRQ_HANDLED;
> +}
> +
[...]
> +
> +static struct irqaction mtk_timer_irq = {
> +	.name = "mtk_timer0",
> +	.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,

IRQF_DISABLED is a nop. Remove it.

> +	.handler = mtk_timer_interrupt,
> +	.dev_id = &mtk_clockevent,
> +};
> +
> +static u32 mtk_timer_sched_read(void)
> +{
> +	return readl(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC));
> +}

This is unused unless you register a sched_clock source.

> +
> +static void __init mtk_timer_init(struct device_node *node)
> +{
> +	unsigned long rate = 0;
> +	struct clk *clk;
> +	int ret, irq;
> +	u32 val;
> +
> +	gpt_base = of_iomap(node, 0);
> +	if (!gpt_base)
> +		panic("Can't map registers");
> +
> +	irq = irq_of_parse_and_map(node, 0);
> +	if (irq <= 0)
> +		panic("Can't parse IRQ");
> +
> +	clk = of_clk_get_by_name(node, "sys_clk");
> +	if (IS_ERR(clk))
> +		panic("Can't get timer clock");
> +	clk_prepare_enable(clk);
> +
> +	rate = clk_get_rate(clk);
> +
> +	mtk_timer_global_reset();
> +
> +	/* Configure clock source */
> +	mtk_timer_reset(GPT_CLK_SRC);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_SRC));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_FREERUN) | TIMER_CTRL_ENABLE,
> +				gpt_base + TIMER_CTRL_REG(GPT_CLK_SRC));
> +
> +	clocksource_mmio_init(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), node->name,
> +			      rate, 300, 32, clocksource_mmio_readl_up);
> +
> +	ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
> +
> +	/* Configure clock event */
> +	mtk_timer_reset(GPT_CLK_EVT);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_EVT));
> +	writel(0, gpt_base + TIMER_CMP_REG(GPT_CLK_EVT));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT) | TIMER_CTRL_ENABLE,
> +			gpt_base + TIMER_CTRL_REG(GPT_CLK_EVT));
> +
> +	ret = setup_irq(irq, &mtk_timer_irq);

Most clocksource drivers use request_irq() nowadays. Can you use
that?

> +	if (ret)
> +		pr_warn("failed to setup irq %d\n", irq);
> +
> +	/* Enable timer0 interrupt */
> +	val = readl(gpt_base + GPT_IRQ_EN_REG);
> +	writel(val | GPT_IRQ_ENABLE(GPT_CLK_EVT), gpt_base + GPT_IRQ_EN_REG);
> +
> +	mtk_clockevent.cpumask = cpumask_of(0);

Is it possible for this timer to be used on SMP hardware? If so,
this should probably be cpu_all_mask. Please assign the .irq
member here as well.

> +
> +	clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
> +					0xffffffff);
> +}
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 20:58     ` Stephen Boyd
  0 siblings, 0 replies; 74+ messages in thread
From: Stephen Boyd @ 2014-04-09 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/09, Matthias Brugger wrote:
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 96918e1..bb29321 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -144,6 +144,10 @@ config VF_PIT_TIMER
>  config SYS_SUPPORTS_SH_CMT
>          bool
>  
> +config MTK_TIMER
> +	bool
> +
> +

Why two newlines?

> diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
> new file mode 100644
> index 0000000..bf901e3
> --- /dev/null
> +++ b/drivers/clocksource/mtk_timer.c
> @@ -0,0 +1,248 @@
> +
> +#include <linux/clk.h>
> +#include <linux/clockchips.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/irqreturn.h>
> +#include <linux/sched_clock.h>

Were you planning on registering a sched_clock source?

> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +
[...]
> +
> +static struct clock_event_device mtk_clockevent = {
> +	.name = "mtk_tick",
> +	.rating = 300,
> +	.shift = 32,

This is unnecessary as it's handled by
clockevents_config_and_register().

> +	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
> +	.set_mode = mtk_clkevt_mode,
> +	.set_next_event = mtk_clkevt_next_event,
> +};
> +
> +
> +static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
> +{
> +	struct clock_event_device *evt = (struct clock_event_device *)dev_id;

Unnecessary cast from void.

> +
> +	/* Acknowledge timer0 irq */
> +	writel(GPT_IRQ_ACK(GPT_CLK_EVT), gpt_base + GPT_IRQ_ACK_REG);
> +	evt->event_handler(evt);
> +
> +	return IRQ_HANDLED;
> +}
> +
[...]
> +
> +static struct irqaction mtk_timer_irq = {
> +	.name = "mtk_timer0",
> +	.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,

IRQF_DISABLED is a nop. Remove it.

> +	.handler = mtk_timer_interrupt,
> +	.dev_id = &mtk_clockevent,
> +};
> +
> +static u32 mtk_timer_sched_read(void)
> +{
> +	return readl(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC));
> +}

This is unused unless you register a sched_clock source.

> +
> +static void __init mtk_timer_init(struct device_node *node)
> +{
> +	unsigned long rate = 0;
> +	struct clk *clk;
> +	int ret, irq;
> +	u32 val;
> +
> +	gpt_base = of_iomap(node, 0);
> +	if (!gpt_base)
> +		panic("Can't map registers");
> +
> +	irq = irq_of_parse_and_map(node, 0);
> +	if (irq <= 0)
> +		panic("Can't parse IRQ");
> +
> +	clk = of_clk_get_by_name(node, "sys_clk");
> +	if (IS_ERR(clk))
> +		panic("Can't get timer clock");
> +	clk_prepare_enable(clk);
> +
> +	rate = clk_get_rate(clk);
> +
> +	mtk_timer_global_reset();
> +
> +	/* Configure clock source */
> +	mtk_timer_reset(GPT_CLK_SRC);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_SRC));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_FREERUN) | TIMER_CTRL_ENABLE,
> +				gpt_base + TIMER_CTRL_REG(GPT_CLK_SRC));
> +
> +	clocksource_mmio_init(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), node->name,
> +			      rate, 300, 32, clocksource_mmio_readl_up);
> +
> +	ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
> +
> +	/* Configure clock event */
> +	mtk_timer_reset(GPT_CLK_EVT);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_EVT));
> +	writel(0, gpt_base + TIMER_CMP_REG(GPT_CLK_EVT));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT) | TIMER_CTRL_ENABLE,
> +			gpt_base + TIMER_CTRL_REG(GPT_CLK_EVT));
> +
> +	ret = setup_irq(irq, &mtk_timer_irq);

Most clocksource drivers use request_irq() nowadays. Can you use
that?

> +	if (ret)
> +		pr_warn("failed to setup irq %d\n", irq);
> +
> +	/* Enable timer0 interrupt */
> +	val = readl(gpt_base + GPT_IRQ_EN_REG);
> +	writel(val | GPT_IRQ_ENABLE(GPT_CLK_EVT), gpt_base + GPT_IRQ_EN_REG);
> +
> +	mtk_clockevent.cpumask = cpumask_of(0);

Is it possible for this timer to be used on SMP hardware? If so,
this should probably be cpu_all_mask. Please assign the .irq
member here as well.

> +
> +	clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
> +					0xffffffff);
> +}
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

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

* Re: [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 21:08     ` Gregory CLEMENT
  0 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-09 21:08 UTC (permalink / raw)
  To: Matthias Brugger, linux-kernel
  Cc: mark.rutland, andrew, linux-doc, thierry.reding, heiko.stuebner,
	linux, daniel.lezcano, florian.vaussard, sebastian.hesselbarth,
	devicetree, jason, pawel.moll, ijc+devicetree, robh+dt, tglx,
	linux-arm-kernel, rdunlap, silvio.fricke, galak, olof, jic23

Hi Matthias,

On 09/04/2014 19:45, Matthias Brugger wrote:
> This patch adds a clock source and clock event for the timer found
> on the Mediatek SoCs.
> 
> The Mediatek General Porpose Timer block provides five 32 bit timers and
> one 64 bit timer.
> 
> Two 32 bit timers are used:
> TIMER1: clock events supporting periodic and oneshot events
> TIMER2: clock source configured as a free running counter
> 
> The General Porpose Timer block can be run with two clocks. A 13 MHz system
> clock and the RTC clock running at 32 KHz. This implementation uses the system
> clock.
> 
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  drivers/clocksource/Kconfig     |    4 +
>  drivers/clocksource/Makefile    |    1 +
>  drivers/clocksource/mtk_timer.c |  248 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 253 insertions(+)
>  create mode 100644 drivers/clocksource/mtk_timer.c
> 
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 96918e1..bb29321 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -144,6 +144,10 @@ config VF_PIT_TIMER
>  config SYS_SUPPORTS_SH_CMT
>          bool
>  
> +config MTK_TIMER
> +	bool
> +
> +
>  config SYS_SUPPORTS_SH_MTU2
>          bool
>  
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 98cb6c5..619d302 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -33,6 +33,7 @@ obj-$(CONFIG_CLKSRC_EXYNOS_MCT)	+= exynos_mct.o
>  obj-$(CONFIG_CLKSRC_SAMSUNG_PWM)	+= samsung_pwm_timer.o
>  obj-$(CONFIG_VF_PIT_TIMER)	+= vf_pit_timer.o
>  obj-$(CONFIG_CLKSRC_QCOM)	+= qcom-timer.o
> +obj-$(CONFIG_MTK_TIMER)		+= mtk_timer.o
>  
>  obj-$(CONFIG_ARM_ARCH_TIMER)		+= arm_arch_timer.o
>  obj-$(CONFIG_ARM_GLOBAL_TIMER)		+= arm_global_timer.o
> diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
> new file mode 100644
> index 0000000..bf901e3
> --- /dev/null
> +++ b/drivers/clocksource/mtk_timer.c
> @@ -0,0 +1,248 @@
> +/*
> + * Mediatek SoCs General-Purpose Timer handling.
> + *
> + * Copyright (C) 2014 Matthias Brugger
> + *
> + * Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/clockchips.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/irqreturn.h>
> +#include <linux/sched_clock.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +
> +#define GPT_IRQ_EN_REG		0x00
> +#define GPT_IRQ_ENABLE(val)	BIT(val-1)
> +#define GPT_IRQ_ST_REG		0x04
> +#define GPT_IRQ_ACK_REG		0x08
> +#define GPT_IRQ_ACK(val)	BIT(val-1)
> +
> +#define TIMER_CTRL_REG(val)	(0x10 * val)
> +#define TIMER_CTRL_OP(val)	(((val) & 0x3) << 4)
> +#define TIMER_CTRL_OP_ONESHOT	(0)
> +#define TIMER_CTRL_OP_REPEAT	(1)
> +#define TIMER_CTRL_OP_KEEPGO	(2)
> +#define TIMER_CTRL_OP_FREERUN	(3)
> +#define TIMER_CTRL_CLEAR	(2)
> +#define TIMER_CTRL_ENABLE	(1)
> +#define TIMER_CTRL_DISABLE	(0)
> +
> +#define TIMER_CLK_REG(val)	(0x04 + (0x10 * val))
> +#define TIMER_CLK_SRC(val)	(((val) & 0x1) << 4)
> +#define TIMER_CLK_SRC_SYS13M	(0)
> +#define TIMER_CLK_SRC_RTC32K	(1)
> +#define TIMER_CLK_DIV1		(0x0)
> +#define TIMER_CLK_DIV2		(0x1)
> +#define TIMER_CLK_DIV3		(0x2)
> +#define TIMER_CLK_DIV4		(0x3)
> +#define TIMER_CLK_DIV5		(0x4)
> +#define TIMER_CLK_DIV6		(0x5)
> +#define TIMER_CLK_DIV7		(0x6)
> +#define TIMER_CLK_DIV8		(0x7)
> +#define TIMER_CLK_DIV9		(0x8)
> +#define TIMER_CLK_DIV10		(0x9)
> +#define TIMER_CLK_DIV11		(0xA)
> +#define TIMER_CLK_DIV12		(0xB)
> +#define TIMER_CLK_DIV13		(0xC)
> +#define TIMER_CLK_DIV16		(0xD)
> +#define TIMER_CLK_DIV32		(0xE)
> +#define TIMER_CLK_DIV64		(0xF)
> +
> +#define TIMER_CNT_REG(val)	(0x08 + (0x10 * val))
> +#define TIMER_CMP_REG(val)	(0x0C + (0x10 * val))
> +
> +#define GPT_CLK_EVT	1
> +#define GPT_CLK_SRC	2
> +
> +static void __iomem *gpt_base;
> +static u32 ticks_per_jiffy;
> +
> +static void mtk_clkevt_time_stop(u8 timer)
> +{
> +	u32 val = readl(gpt_base + TIMER_CTRL_REG(timer));
> +	writel(val & ~TIMER_CTRL_ENABLE, gpt_base + TIMER_CTRL_REG(timer));
> +}
> +
> +static void mtk_clkevt_time_setup(unsigned long delay, u8 timer)
> +{
> +	writel(delay, gpt_base + TIMER_CMP_REG(timer));
> +}
> +
> +static void mtk_clkevt_time_start(bool periodic, u8 timer)
> +{
> +	u32 val;
> +
> +	/* Acknowledge interrupt */
> +	writel(GPT_IRQ_ACK(timer), gpt_base + GPT_IRQ_ACK_REG);
> +
> +	val = readl(gpt_base + TIMER_CTRL_REG(timer));
> +
> +	/* Clear 2 bit timer operation mode field */
> +	val &= ~TIMER_CTRL_OP(0x3);
> +
> +	if (periodic)
> +		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT);
> +	else
> +		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_ONESHOT);
> +
> +	writel(val | TIMER_CTRL_ENABLE | TIMER_CTRL_CLEAR,
> +	       gpt_base + TIMER_CTRL_REG(timer));
> +}
> +
> +static void mtk_clkevt_mode(enum clock_event_mode mode,
> +			      struct clock_event_device *clk)
> +{
> +	mtk_clkevt_time_stop(GPT_CLK_EVT);
> +
> +	switch (mode) {
> +	case CLOCK_EVT_MODE_PERIODIC:
> +		mtk_clkevt_time_setup(ticks_per_jiffy, GPT_CLK_EVT);
> +		mtk_clkevt_time_start(true, GPT_CLK_EVT);
> +		break;
> +	case CLOCK_EVT_MODE_ONESHOT:
> +		mtk_clkevt_time_start(false, GPT_CLK_EVT);
> +		break;
> +	case CLOCK_EVT_MODE_UNUSED:
> +	case CLOCK_EVT_MODE_SHUTDOWN:
> +	default:
> +		/* No more interrupts will occur as source is disabled */
> +		break;
> +	}
> +}
> +
> +static int mtk_clkevt_next_event(unsigned long evt,
> +				   struct clock_event_device *unused)
> +{
> +	mtk_clkevt_time_stop(GPT_CLK_EVT);
> +	mtk_clkevt_time_setup(evt, GPT_CLK_EVT);
> +	mtk_clkevt_time_start(false, GPT_CLK_EVT);
> +
> +	return 0;
> +}
> +
> +static struct clock_event_device mtk_clockevent = {
> +	.name = "mtk_tick",
> +	.rating = 300,
> +	.shift = 32,
> +	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
> +	.set_mode = mtk_clkevt_mode,
> +	.set_next_event = mtk_clkevt_next_event,
> +};
> +
> +
> +static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
> +{
> +	struct clock_event_device *evt = (struct clock_event_device *)dev_id;
> +
> +	/* Acknowledge timer0 irq */
> +	writel(GPT_IRQ_ACK(GPT_CLK_EVT), gpt_base + GPT_IRQ_ACK_REG);
> +	evt->event_handler(evt);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static void mtk_timer_global_reset(void)
> +{
> +	/* Disable all interrupts */
> +	writel(0x0, gpt_base + GPT_IRQ_EN_REG);
> +	/* Acknowledge all interrupts */
> +	writel(0x3f, gpt_base + GPT_IRQ_ACK_REG);
> +}
> +
> +static void mtk_timer_reset(u8 timer)
> +{
> +	writel(TIMER_CTRL_CLEAR | TIMER_CTRL_DISABLE,
> +		gpt_base + TIMER_CTRL_REG(timer));
> +	writel(0x0, gpt_base + TIMER_CMP_REG(timer));
> +}
> +
> +static struct irqaction mtk_timer_irq = {
> +	.name = "mtk_timer0",
> +	.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
> +	.handler = mtk_timer_interrupt,
> +	.dev_id = &mtk_clockevent,
> +};
> +
> +static u32 mtk_timer_sched_read(void)
> +{
> +	return readl(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC));
> +}
> +
> +static void __init mtk_timer_init(struct device_node *node)
> +{
> +	unsigned long rate = 0;
> +	struct clk *clk;
> +	int ret, irq;
> +	u32 val;
> +
> +	gpt_base = of_iomap(node, 0);

What about using of_address_to_resource()? Then you will be
able to use request_mem_region() before calling ioremap().

> +	if (!gpt_base)
> +		panic("Can't map registers");
> +
> +	irq = irq_of_parse_and_map(node, 0);
> +	if (irq <= 0)
> +		panic("Can't parse IRQ");
> +
> +	clk = of_clk_get_by_name(node, "sys_clk");

We try to avoid to used named clock. You should use
of_clk_get(np, 0) here.


Thanks,

Gregory


> +	if (IS_ERR(clk))
> +		panic("Can't get timer clock");
> +	clk_prepare_enable(clk);
> +
> +	rate = clk_get_rate(clk);
> +
> +	mtk_timer_global_reset();
> +
> +	/* Configure clock source */
> +	mtk_timer_reset(GPT_CLK_SRC);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_SRC));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_FREERUN) | TIMER_CTRL_ENABLE,
> +				gpt_base + TIMER_CTRL_REG(GPT_CLK_SRC));
> +
> +	clocksource_mmio_init(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), node->name,
> +			      rate, 300, 32, clocksource_mmio_readl_up);
> +
> +	ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
> +
> +	/* Configure clock event */
> +	mtk_timer_reset(GPT_CLK_EVT);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_EVT));
> +	writel(0, gpt_base + TIMER_CMP_REG(GPT_CLK_EVT));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT) | TIMER_CTRL_ENABLE,
> +			gpt_base + TIMER_CTRL_REG(GPT_CLK_EVT));
> +
> +	ret = setup_irq(irq, &mtk_timer_irq);
> +	if (ret)
> +		pr_warn("failed to setup irq %d\n", irq);
> +
> +	/* Enable timer0 interrupt */
> +	val = readl(gpt_base + GPT_IRQ_EN_REG);
> +	writel(val | GPT_IRQ_ENABLE(GPT_CLK_EVT), gpt_base + GPT_IRQ_EN_REG);
> +
> +	mtk_clockevent.cpumask = cpumask_of(0);
> +
> +	clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
> +					0xffffffff);
> +}
> +CLOCKSOURCE_OF_DECLARE(mtk_mt6589, "mediatek,mtk6589-timer", mtk_timer_init);
> +
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 21:08     ` Gregory CLEMENT
  0 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-09 21:08 UTC (permalink / raw)
  To: Matthias Brugger, linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: mark.rutland-5wv7dgnIgG8, andrew-g2DYL2Zd6BY,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	thierry.reding-Re5JQEeQqe8AvxtiuMwx3w,
	heiko.stuebner-K3U4GQvHnyU, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A,
	florian.vaussard-p8DiymsW2f8,
	sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-u79uwXL29TY76Z2rM5mHXA, jason-NLaQJdtUoK4Be96aLqz0jA,
	pawel.moll-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, tglx-hfZtesqFncYOwBW4kG4KsQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	rdunlap-wEGCiKHe2LqWVfeAwA7xHQ,
	silvio.fricke-Re5JQEeQqe8AvxtiuMwx3w,
	galak-sgV2jX0FEOL9JmXXK+q4OQ, olof-nZhT3qVonbNeoWH0uzbU5w,
	jic23-DgEjT+Ai2ygdnm+yROfE0A

Hi Matthias,

On 09/04/2014 19:45, Matthias Brugger wrote:
> This patch adds a clock source and clock event for the timer found
> on the Mediatek SoCs.
> 
> The Mediatek General Porpose Timer block provides five 32 bit timers and
> one 64 bit timer.
> 
> Two 32 bit timers are used:
> TIMER1: clock events supporting periodic and oneshot events
> TIMER2: clock source configured as a free running counter
> 
> The General Porpose Timer block can be run with two clocks. A 13 MHz system
> clock and the RTC clock running at 32 KHz. This implementation uses the system
> clock.
> 
> Signed-off-by: Matthias Brugger <matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/clocksource/Kconfig     |    4 +
>  drivers/clocksource/Makefile    |    1 +
>  drivers/clocksource/mtk_timer.c |  248 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 253 insertions(+)
>  create mode 100644 drivers/clocksource/mtk_timer.c
> 
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 96918e1..bb29321 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -144,6 +144,10 @@ config VF_PIT_TIMER
>  config SYS_SUPPORTS_SH_CMT
>          bool
>  
> +config MTK_TIMER
> +	bool
> +
> +
>  config SYS_SUPPORTS_SH_MTU2
>          bool
>  
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 98cb6c5..619d302 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -33,6 +33,7 @@ obj-$(CONFIG_CLKSRC_EXYNOS_MCT)	+= exynos_mct.o
>  obj-$(CONFIG_CLKSRC_SAMSUNG_PWM)	+= samsung_pwm_timer.o
>  obj-$(CONFIG_VF_PIT_TIMER)	+= vf_pit_timer.o
>  obj-$(CONFIG_CLKSRC_QCOM)	+= qcom-timer.o
> +obj-$(CONFIG_MTK_TIMER)		+= mtk_timer.o
>  
>  obj-$(CONFIG_ARM_ARCH_TIMER)		+= arm_arch_timer.o
>  obj-$(CONFIG_ARM_GLOBAL_TIMER)		+= arm_global_timer.o
> diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
> new file mode 100644
> index 0000000..bf901e3
> --- /dev/null
> +++ b/drivers/clocksource/mtk_timer.c
> @@ -0,0 +1,248 @@
> +/*
> + * Mediatek SoCs General-Purpose Timer handling.
> + *
> + * Copyright (C) 2014 Matthias Brugger
> + *
> + * Matthias Brugger <matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/clockchips.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/irqreturn.h>
> +#include <linux/sched_clock.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +
> +#define GPT_IRQ_EN_REG		0x00
> +#define GPT_IRQ_ENABLE(val)	BIT(val-1)
> +#define GPT_IRQ_ST_REG		0x04
> +#define GPT_IRQ_ACK_REG		0x08
> +#define GPT_IRQ_ACK(val)	BIT(val-1)
> +
> +#define TIMER_CTRL_REG(val)	(0x10 * val)
> +#define TIMER_CTRL_OP(val)	(((val) & 0x3) << 4)
> +#define TIMER_CTRL_OP_ONESHOT	(0)
> +#define TIMER_CTRL_OP_REPEAT	(1)
> +#define TIMER_CTRL_OP_KEEPGO	(2)
> +#define TIMER_CTRL_OP_FREERUN	(3)
> +#define TIMER_CTRL_CLEAR	(2)
> +#define TIMER_CTRL_ENABLE	(1)
> +#define TIMER_CTRL_DISABLE	(0)
> +
> +#define TIMER_CLK_REG(val)	(0x04 + (0x10 * val))
> +#define TIMER_CLK_SRC(val)	(((val) & 0x1) << 4)
> +#define TIMER_CLK_SRC_SYS13M	(0)
> +#define TIMER_CLK_SRC_RTC32K	(1)
> +#define TIMER_CLK_DIV1		(0x0)
> +#define TIMER_CLK_DIV2		(0x1)
> +#define TIMER_CLK_DIV3		(0x2)
> +#define TIMER_CLK_DIV4		(0x3)
> +#define TIMER_CLK_DIV5		(0x4)
> +#define TIMER_CLK_DIV6		(0x5)
> +#define TIMER_CLK_DIV7		(0x6)
> +#define TIMER_CLK_DIV8		(0x7)
> +#define TIMER_CLK_DIV9		(0x8)
> +#define TIMER_CLK_DIV10		(0x9)
> +#define TIMER_CLK_DIV11		(0xA)
> +#define TIMER_CLK_DIV12		(0xB)
> +#define TIMER_CLK_DIV13		(0xC)
> +#define TIMER_CLK_DIV16		(0xD)
> +#define TIMER_CLK_DIV32		(0xE)
> +#define TIMER_CLK_DIV64		(0xF)
> +
> +#define TIMER_CNT_REG(val)	(0x08 + (0x10 * val))
> +#define TIMER_CMP_REG(val)	(0x0C + (0x10 * val))
> +
> +#define GPT_CLK_EVT	1
> +#define GPT_CLK_SRC	2
> +
> +static void __iomem *gpt_base;
> +static u32 ticks_per_jiffy;
> +
> +static void mtk_clkevt_time_stop(u8 timer)
> +{
> +	u32 val = readl(gpt_base + TIMER_CTRL_REG(timer));
> +	writel(val & ~TIMER_CTRL_ENABLE, gpt_base + TIMER_CTRL_REG(timer));
> +}
> +
> +static void mtk_clkevt_time_setup(unsigned long delay, u8 timer)
> +{
> +	writel(delay, gpt_base + TIMER_CMP_REG(timer));
> +}
> +
> +static void mtk_clkevt_time_start(bool periodic, u8 timer)
> +{
> +	u32 val;
> +
> +	/* Acknowledge interrupt */
> +	writel(GPT_IRQ_ACK(timer), gpt_base + GPT_IRQ_ACK_REG);
> +
> +	val = readl(gpt_base + TIMER_CTRL_REG(timer));
> +
> +	/* Clear 2 bit timer operation mode field */
> +	val &= ~TIMER_CTRL_OP(0x3);
> +
> +	if (periodic)
> +		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT);
> +	else
> +		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_ONESHOT);
> +
> +	writel(val | TIMER_CTRL_ENABLE | TIMER_CTRL_CLEAR,
> +	       gpt_base + TIMER_CTRL_REG(timer));
> +}
> +
> +static void mtk_clkevt_mode(enum clock_event_mode mode,
> +			      struct clock_event_device *clk)
> +{
> +	mtk_clkevt_time_stop(GPT_CLK_EVT);
> +
> +	switch (mode) {
> +	case CLOCK_EVT_MODE_PERIODIC:
> +		mtk_clkevt_time_setup(ticks_per_jiffy, GPT_CLK_EVT);
> +		mtk_clkevt_time_start(true, GPT_CLK_EVT);
> +		break;
> +	case CLOCK_EVT_MODE_ONESHOT:
> +		mtk_clkevt_time_start(false, GPT_CLK_EVT);
> +		break;
> +	case CLOCK_EVT_MODE_UNUSED:
> +	case CLOCK_EVT_MODE_SHUTDOWN:
> +	default:
> +		/* No more interrupts will occur as source is disabled */
> +		break;
> +	}
> +}
> +
> +static int mtk_clkevt_next_event(unsigned long evt,
> +				   struct clock_event_device *unused)
> +{
> +	mtk_clkevt_time_stop(GPT_CLK_EVT);
> +	mtk_clkevt_time_setup(evt, GPT_CLK_EVT);
> +	mtk_clkevt_time_start(false, GPT_CLK_EVT);
> +
> +	return 0;
> +}
> +
> +static struct clock_event_device mtk_clockevent = {
> +	.name = "mtk_tick",
> +	.rating = 300,
> +	.shift = 32,
> +	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
> +	.set_mode = mtk_clkevt_mode,
> +	.set_next_event = mtk_clkevt_next_event,
> +};
> +
> +
> +static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
> +{
> +	struct clock_event_device *evt = (struct clock_event_device *)dev_id;
> +
> +	/* Acknowledge timer0 irq */
> +	writel(GPT_IRQ_ACK(GPT_CLK_EVT), gpt_base + GPT_IRQ_ACK_REG);
> +	evt->event_handler(evt);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static void mtk_timer_global_reset(void)
> +{
> +	/* Disable all interrupts */
> +	writel(0x0, gpt_base + GPT_IRQ_EN_REG);
> +	/* Acknowledge all interrupts */
> +	writel(0x3f, gpt_base + GPT_IRQ_ACK_REG);
> +}
> +
> +static void mtk_timer_reset(u8 timer)
> +{
> +	writel(TIMER_CTRL_CLEAR | TIMER_CTRL_DISABLE,
> +		gpt_base + TIMER_CTRL_REG(timer));
> +	writel(0x0, gpt_base + TIMER_CMP_REG(timer));
> +}
> +
> +static struct irqaction mtk_timer_irq = {
> +	.name = "mtk_timer0",
> +	.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
> +	.handler = mtk_timer_interrupt,
> +	.dev_id = &mtk_clockevent,
> +};
> +
> +static u32 mtk_timer_sched_read(void)
> +{
> +	return readl(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC));
> +}
> +
> +static void __init mtk_timer_init(struct device_node *node)
> +{
> +	unsigned long rate = 0;
> +	struct clk *clk;
> +	int ret, irq;
> +	u32 val;
> +
> +	gpt_base = of_iomap(node, 0);

What about using of_address_to_resource()? Then you will be
able to use request_mem_region() before calling ioremap().

> +	if (!gpt_base)
> +		panic("Can't map registers");
> +
> +	irq = irq_of_parse_and_map(node, 0);
> +	if (irq <= 0)
> +		panic("Can't parse IRQ");
> +
> +	clk = of_clk_get_by_name(node, "sys_clk");

We try to avoid to used named clock. You should use
of_clk_get(np, 0) here.


Thanks,

Gregory


> +	if (IS_ERR(clk))
> +		panic("Can't get timer clock");
> +	clk_prepare_enable(clk);
> +
> +	rate = clk_get_rate(clk);
> +
> +	mtk_timer_global_reset();
> +
> +	/* Configure clock source */
> +	mtk_timer_reset(GPT_CLK_SRC);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_SRC));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_FREERUN) | TIMER_CTRL_ENABLE,
> +				gpt_base + TIMER_CTRL_REG(GPT_CLK_SRC));
> +
> +	clocksource_mmio_init(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), node->name,
> +			      rate, 300, 32, clocksource_mmio_readl_up);
> +
> +	ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
> +
> +	/* Configure clock event */
> +	mtk_timer_reset(GPT_CLK_EVT);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_EVT));
> +	writel(0, gpt_base + TIMER_CMP_REG(GPT_CLK_EVT));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT) | TIMER_CTRL_ENABLE,
> +			gpt_base + TIMER_CTRL_REG(GPT_CLK_EVT));
> +
> +	ret = setup_irq(irq, &mtk_timer_irq);
> +	if (ret)
> +		pr_warn("failed to setup irq %d\n", irq);
> +
> +	/* Enable timer0 interrupt */
> +	val = readl(gpt_base + GPT_IRQ_EN_REG);
> +	writel(val | GPT_IRQ_ENABLE(GPT_CLK_EVT), gpt_base + GPT_IRQ_EN_REG);
> +
> +	mtk_clockevent.cpumask = cpumask_of(0);
> +
> +	clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
> +					0xffffffff);
> +}
> +CLOCKSOURCE_OF_DECLARE(mtk_mt6589, "mediatek,mtk6589-timer", mtk_timer_init);
> +
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 21:08     ` Gregory CLEMENT
  0 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-09 21:08 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Matthias,

On 09/04/2014 19:45, Matthias Brugger wrote:
> This patch adds a clock source and clock event for the timer found
> on the Mediatek SoCs.
> 
> The Mediatek General Porpose Timer block provides five 32 bit timers and
> one 64 bit timer.
> 
> Two 32 bit timers are used:
> TIMER1: clock events supporting periodic and oneshot events
> TIMER2: clock source configured as a free running counter
> 
> The General Porpose Timer block can be run with two clocks. A 13 MHz system
> clock and the RTC clock running at 32 KHz. This implementation uses the system
> clock.
> 
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  drivers/clocksource/Kconfig     |    4 +
>  drivers/clocksource/Makefile    |    1 +
>  drivers/clocksource/mtk_timer.c |  248 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 253 insertions(+)
>  create mode 100644 drivers/clocksource/mtk_timer.c
> 
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 96918e1..bb29321 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -144,6 +144,10 @@ config VF_PIT_TIMER
>  config SYS_SUPPORTS_SH_CMT
>          bool
>  
> +config MTK_TIMER
> +	bool
> +
> +
>  config SYS_SUPPORTS_SH_MTU2
>          bool
>  
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 98cb6c5..619d302 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -33,6 +33,7 @@ obj-$(CONFIG_CLKSRC_EXYNOS_MCT)	+= exynos_mct.o
>  obj-$(CONFIG_CLKSRC_SAMSUNG_PWM)	+= samsung_pwm_timer.o
>  obj-$(CONFIG_VF_PIT_TIMER)	+= vf_pit_timer.o
>  obj-$(CONFIG_CLKSRC_QCOM)	+= qcom-timer.o
> +obj-$(CONFIG_MTK_TIMER)		+= mtk_timer.o
>  
>  obj-$(CONFIG_ARM_ARCH_TIMER)		+= arm_arch_timer.o
>  obj-$(CONFIG_ARM_GLOBAL_TIMER)		+= arm_global_timer.o
> diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
> new file mode 100644
> index 0000000..bf901e3
> --- /dev/null
> +++ b/drivers/clocksource/mtk_timer.c
> @@ -0,0 +1,248 @@
> +/*
> + * Mediatek SoCs General-Purpose Timer handling.
> + *
> + * Copyright (C) 2014 Matthias Brugger
> + *
> + * Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/clockchips.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/irqreturn.h>
> +#include <linux/sched_clock.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +
> +#define GPT_IRQ_EN_REG		0x00
> +#define GPT_IRQ_ENABLE(val)	BIT(val-1)
> +#define GPT_IRQ_ST_REG		0x04
> +#define GPT_IRQ_ACK_REG		0x08
> +#define GPT_IRQ_ACK(val)	BIT(val-1)
> +
> +#define TIMER_CTRL_REG(val)	(0x10 * val)
> +#define TIMER_CTRL_OP(val)	(((val) & 0x3) << 4)
> +#define TIMER_CTRL_OP_ONESHOT	(0)
> +#define TIMER_CTRL_OP_REPEAT	(1)
> +#define TIMER_CTRL_OP_KEEPGO	(2)
> +#define TIMER_CTRL_OP_FREERUN	(3)
> +#define TIMER_CTRL_CLEAR	(2)
> +#define TIMER_CTRL_ENABLE	(1)
> +#define TIMER_CTRL_DISABLE	(0)
> +
> +#define TIMER_CLK_REG(val)	(0x04 + (0x10 * val))
> +#define TIMER_CLK_SRC(val)	(((val) & 0x1) << 4)
> +#define TIMER_CLK_SRC_SYS13M	(0)
> +#define TIMER_CLK_SRC_RTC32K	(1)
> +#define TIMER_CLK_DIV1		(0x0)
> +#define TIMER_CLK_DIV2		(0x1)
> +#define TIMER_CLK_DIV3		(0x2)
> +#define TIMER_CLK_DIV4		(0x3)
> +#define TIMER_CLK_DIV5		(0x4)
> +#define TIMER_CLK_DIV6		(0x5)
> +#define TIMER_CLK_DIV7		(0x6)
> +#define TIMER_CLK_DIV8		(0x7)
> +#define TIMER_CLK_DIV9		(0x8)
> +#define TIMER_CLK_DIV10		(0x9)
> +#define TIMER_CLK_DIV11		(0xA)
> +#define TIMER_CLK_DIV12		(0xB)
> +#define TIMER_CLK_DIV13		(0xC)
> +#define TIMER_CLK_DIV16		(0xD)
> +#define TIMER_CLK_DIV32		(0xE)
> +#define TIMER_CLK_DIV64		(0xF)
> +
> +#define TIMER_CNT_REG(val)	(0x08 + (0x10 * val))
> +#define TIMER_CMP_REG(val)	(0x0C + (0x10 * val))
> +
> +#define GPT_CLK_EVT	1
> +#define GPT_CLK_SRC	2
> +
> +static void __iomem *gpt_base;
> +static u32 ticks_per_jiffy;
> +
> +static void mtk_clkevt_time_stop(u8 timer)
> +{
> +	u32 val = readl(gpt_base + TIMER_CTRL_REG(timer));
> +	writel(val & ~TIMER_CTRL_ENABLE, gpt_base + TIMER_CTRL_REG(timer));
> +}
> +
> +static void mtk_clkevt_time_setup(unsigned long delay, u8 timer)
> +{
> +	writel(delay, gpt_base + TIMER_CMP_REG(timer));
> +}
> +
> +static void mtk_clkevt_time_start(bool periodic, u8 timer)
> +{
> +	u32 val;
> +
> +	/* Acknowledge interrupt */
> +	writel(GPT_IRQ_ACK(timer), gpt_base + GPT_IRQ_ACK_REG);
> +
> +	val = readl(gpt_base + TIMER_CTRL_REG(timer));
> +
> +	/* Clear 2 bit timer operation mode field */
> +	val &= ~TIMER_CTRL_OP(0x3);
> +
> +	if (periodic)
> +		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT);
> +	else
> +		val |= TIMER_CTRL_OP(TIMER_CTRL_OP_ONESHOT);
> +
> +	writel(val | TIMER_CTRL_ENABLE | TIMER_CTRL_CLEAR,
> +	       gpt_base + TIMER_CTRL_REG(timer));
> +}
> +
> +static void mtk_clkevt_mode(enum clock_event_mode mode,
> +			      struct clock_event_device *clk)
> +{
> +	mtk_clkevt_time_stop(GPT_CLK_EVT);
> +
> +	switch (mode) {
> +	case CLOCK_EVT_MODE_PERIODIC:
> +		mtk_clkevt_time_setup(ticks_per_jiffy, GPT_CLK_EVT);
> +		mtk_clkevt_time_start(true, GPT_CLK_EVT);
> +		break;
> +	case CLOCK_EVT_MODE_ONESHOT:
> +		mtk_clkevt_time_start(false, GPT_CLK_EVT);
> +		break;
> +	case CLOCK_EVT_MODE_UNUSED:
> +	case CLOCK_EVT_MODE_SHUTDOWN:
> +	default:
> +		/* No more interrupts will occur as source is disabled */
> +		break;
> +	}
> +}
> +
> +static int mtk_clkevt_next_event(unsigned long evt,
> +				   struct clock_event_device *unused)
> +{
> +	mtk_clkevt_time_stop(GPT_CLK_EVT);
> +	mtk_clkevt_time_setup(evt, GPT_CLK_EVT);
> +	mtk_clkevt_time_start(false, GPT_CLK_EVT);
> +
> +	return 0;
> +}
> +
> +static struct clock_event_device mtk_clockevent = {
> +	.name = "mtk_tick",
> +	.rating = 300,
> +	.shift = 32,
> +	.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
> +	.set_mode = mtk_clkevt_mode,
> +	.set_next_event = mtk_clkevt_next_event,
> +};
> +
> +
> +static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
> +{
> +	struct clock_event_device *evt = (struct clock_event_device *)dev_id;
> +
> +	/* Acknowledge timer0 irq */
> +	writel(GPT_IRQ_ACK(GPT_CLK_EVT), gpt_base + GPT_IRQ_ACK_REG);
> +	evt->event_handler(evt);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static void mtk_timer_global_reset(void)
> +{
> +	/* Disable all interrupts */
> +	writel(0x0, gpt_base + GPT_IRQ_EN_REG);
> +	/* Acknowledge all interrupts */
> +	writel(0x3f, gpt_base + GPT_IRQ_ACK_REG);
> +}
> +
> +static void mtk_timer_reset(u8 timer)
> +{
> +	writel(TIMER_CTRL_CLEAR | TIMER_CTRL_DISABLE,
> +		gpt_base + TIMER_CTRL_REG(timer));
> +	writel(0x0, gpt_base + TIMER_CMP_REG(timer));
> +}
> +
> +static struct irqaction mtk_timer_irq = {
> +	.name = "mtk_timer0",
> +	.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
> +	.handler = mtk_timer_interrupt,
> +	.dev_id = &mtk_clockevent,
> +};
> +
> +static u32 mtk_timer_sched_read(void)
> +{
> +	return readl(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC));
> +}
> +
> +static void __init mtk_timer_init(struct device_node *node)
> +{
> +	unsigned long rate = 0;
> +	struct clk *clk;
> +	int ret, irq;
> +	u32 val;
> +
> +	gpt_base = of_iomap(node, 0);

What about using of_address_to_resource()? Then you will be
able to use request_mem_region() before calling ioremap().

> +	if (!gpt_base)
> +		panic("Can't map registers");
> +
> +	irq = irq_of_parse_and_map(node, 0);
> +	if (irq <= 0)
> +		panic("Can't parse IRQ");
> +
> +	clk = of_clk_get_by_name(node, "sys_clk");

We try to avoid to used named clock. You should use
of_clk_get(np, 0) here.


Thanks,

Gregory


> +	if (IS_ERR(clk))
> +		panic("Can't get timer clock");
> +	clk_prepare_enable(clk);
> +
> +	rate = clk_get_rate(clk);
> +
> +	mtk_timer_global_reset();
> +
> +	/* Configure clock source */
> +	mtk_timer_reset(GPT_CLK_SRC);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_SRC));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_FREERUN) | TIMER_CTRL_ENABLE,
> +				gpt_base + TIMER_CTRL_REG(GPT_CLK_SRC));
> +
> +	clocksource_mmio_init(gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), node->name,
> +			      rate, 300, 32, clocksource_mmio_readl_up);
> +
> +	ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
> +
> +	/* Configure clock event */
> +	mtk_timer_reset(GPT_CLK_EVT);
> +
> +	writel(TIMER_CLK_SRC(TIMER_CLK_SRC_SYS13M) | TIMER_CLK_DIV1,
> +			gpt_base + TIMER_CLK_REG(GPT_CLK_EVT));
> +	writel(0, gpt_base + TIMER_CMP_REG(GPT_CLK_EVT));
> +
> +	writel(TIMER_CTRL_OP(TIMER_CTRL_OP_REPEAT) | TIMER_CTRL_ENABLE,
> +			gpt_base + TIMER_CTRL_REG(GPT_CLK_EVT));
> +
> +	ret = setup_irq(irq, &mtk_timer_irq);
> +	if (ret)
> +		pr_warn("failed to setup irq %d\n", irq);
> +
> +	/* Enable timer0 interrupt */
> +	val = readl(gpt_base + GPT_IRQ_EN_REG);
> +	writel(val | GPT_IRQ_ENABLE(GPT_CLK_EVT), gpt_base + GPT_IRQ_EN_REG);
> +
> +	mtk_clockevent.cpumask = cpumask_of(0);
> +
> +	clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
> +					0xffffffff);
> +}
> +CLOCKSOURCE_OF_DECLARE(mtk_mt6589, "mediatek,mtk6589-timer", mtk_timer_init);
> +
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589
  2014-04-09 19:45   ` Matthias Brugger
  (?)
@ 2014-04-09 21:39     ` Rob Herring
  -1 siblings, 0 replies; 74+ messages in thread
From: Rob Herring @ 2014-04-09 21:39 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: linux-kernel, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Randy Dunlap, Russell King - ARM Linux,
	Daniel Lezcano, Thomas Gleixner, Thierry Reding,
	Florian Vaussard, Jonathan Cameron, Jason Cooper, Andrew Lunn,
	Silvio F, heiko.stuebner, Olof Johansson, Sebastian Hesselbarth,
	devicetree, linux-doc, linux-arm-kernel

On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  arch/arm/Kconfig.debug            |   49 +++++++++++++++++++++++++++++++++++--
>  arch/arm/include/debug/mediatek.S |   38 ++++++++++++++++++++++++++++
>  2 files changed, 85 insertions(+), 2 deletions(-)
>  create mode 100644 arch/arm/include/debug/mediatek.S
>
> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
> index 4a2fc0b..dc51495 100644
> --- a/arch/arm/Kconfig.debug
> +++ b/arch/arm/Kconfig.debug
> @@ -797,6 +797,38 @@ choice
>                   Say Y here if you want kernel low-level debugging support
>                   on Ux500 based platforms.
>
> +       config DEBUG_MTK6589_UART0
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART0"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +
> +       config DEBUG_MTK6589_UART1
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART1"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +
> +       config DEBUG_MTK6589_UART2
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART2"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +
> +       config DEBUG_MTK6589_UART3
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART3"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +

Do you really need all uarts defined? Only define what you have boards using.

Also, you have no uarts defined in your dts. Please add them there
(and any necessary serial driver) before adding debug functionality.
Otherwise, you can't actually boot a multi-platform kernel with this
series.

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

* Re: [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589
@ 2014-04-09 21:39     ` Rob Herring
  0 siblings, 0 replies; 74+ messages in thread
From: Rob Herring @ 2014-04-09 21:39 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: linux-kernel, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Randy Dunlap, Russell King - ARM Linux,
	Daniel Lezcano, Thomas Gleixner, Thierry Reding,
	Florian Vaussard, Jonathan Cameron, Jason Cooper, Andrew Lunn,
	Silvio F, heiko.stuebner, Olof Johansson, Sebastian Hesselbarth,
	devicetree, linux-doc

On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  arch/arm/Kconfig.debug            |   49 +++++++++++++++++++++++++++++++++++--
>  arch/arm/include/debug/mediatek.S |   38 ++++++++++++++++++++++++++++
>  2 files changed, 85 insertions(+), 2 deletions(-)
>  create mode 100644 arch/arm/include/debug/mediatek.S
>
> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
> index 4a2fc0b..dc51495 100644
> --- a/arch/arm/Kconfig.debug
> +++ b/arch/arm/Kconfig.debug
> @@ -797,6 +797,38 @@ choice
>                   Say Y here if you want kernel low-level debugging support
>                   on Ux500 based platforms.
>
> +       config DEBUG_MTK6589_UART0
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART0"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +
> +       config DEBUG_MTK6589_UART1
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART1"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +
> +       config DEBUG_MTK6589_UART2
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART2"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +
> +       config DEBUG_MTK6589_UART3
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART3"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +

Do you really need all uarts defined? Only define what you have boards using.

Also, you have no uarts defined in your dts. Please add them there
(and any necessary serial driver) before adding debug functionality.
Otherwise, you can't actually boot a multi-platform kernel with this
series.

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

* [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589
@ 2014-04-09 21:39     ` Rob Herring
  0 siblings, 0 replies; 74+ messages in thread
From: Rob Herring @ 2014-04-09 21:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  arch/arm/Kconfig.debug            |   49 +++++++++++++++++++++++++++++++++++--
>  arch/arm/include/debug/mediatek.S |   38 ++++++++++++++++++++++++++++
>  2 files changed, 85 insertions(+), 2 deletions(-)
>  create mode 100644 arch/arm/include/debug/mediatek.S
>
> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
> index 4a2fc0b..dc51495 100644
> --- a/arch/arm/Kconfig.debug
> +++ b/arch/arm/Kconfig.debug
> @@ -797,6 +797,38 @@ choice
>                   Say Y here if you want kernel low-level debugging support
>                   on Ux500 based platforms.
>
> +       config DEBUG_MTK6589_UART0
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART0"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +
> +       config DEBUG_MTK6589_UART1
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART1"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +
> +       config DEBUG_MTK6589_UART2
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART2"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +
> +       config DEBUG_MTK6589_UART3
> +               depends on ARCH_MEDIATEK
> +               bool "Mediatek mt6589 UART3"
> +               select DEBUG_UART_MEDIATEK
> +               help
> +                 Say Y here if you want kernel low-level debugging support
> +                 on Mediatek mt6589 based platforms.
> +

Do you really need all uarts defined? Only define what you have boards using.

Also, you have no uarts defined in your dts. Please add them there
(and any necessary serial driver) before adding debug functionality.
Otherwise, you can't actually boot a multi-platform kernel with this
series.

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-09 19:45   ` Matthias Brugger
  (?)
@ 2014-04-09 21:50     ` Rob Herring
  -1 siblings, 0 replies; 74+ messages in thread
From: Rob Herring @ 2014-04-09 21:50 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: linux-kernel, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Randy Dunlap, Russell King - ARM Linux,
	Daniel Lezcano, Thomas Gleixner, Thierry Reding,
	Florian Vaussard, Jonathan Cameron, Jason Cooper, Andrew Lunn,
	Silvio F, heiko.stuebner, Olof Johansson, Sebastian Hesselbarth,
	devicetree, linux-doc, linux-arm-kernel

On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
> This adds a generic devicetree board file and a dtsi for boards
> based on the MT6589 SoCs from Mediatek.
>
> Apart from the generic parts (gic, clocks) the only component
> currently supported are the timers.
>
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>  arch/arm/Kconfig                                   |    2 +
>  arch/arm/Makefile                                  |    1 +
>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++

Please add an actual board so your dts file can actually be built.

>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>  arch/arm/mach-mediatek/Makefile                    |    1 +
>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>  7 files changed, 164 insertions(+)
>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>  create mode 100644 arch/arm/mach-mediatek/Makefile
>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
>
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index 0f01c9b..af48801 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -67,6 +67,7 @@ linux Linux-specific binding
>  lsi    LSI Corp. (LSI Logic)
>  marvell        Marvell Technology Group Ltd.
>  maxim  Maxim Integrated Products
> +mediatek       MediaTek Inc.
>  microchip      Microchip Technology Inc.
>  mosaixtech     Mosaix Technologies, Inc.
>  moxa   Moxa
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 5db05f6a..04d46ec 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>
>  source "arch/arm/mach-imx/Kconfig"
>
> +source "arch/arm/mach-mediatek/Kconfig"
> +
>  source "arch/arm/mach-mxs/Kconfig"
>
>  source "arch/arm/mach-netx/Kconfig"
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 41c1931..8ce9774 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)          += msm
>  machine-$(CONFIG_ARCH_MV78XX0)         += mv78xx0
>  machine-$(CONFIG_ARCH_MVEBU)           += mvebu
>  machine-$(CONFIG_ARCH_MXC)             += imx
> +machine-$(CONFIG_ARCH_MEDIATEK)                += mediatek
>  machine-$(CONFIG_ARCH_MXS)             += mxs
>  machine-$(CONFIG_ARCH_NETX)            += netx
>  machine-$(CONFIG_ARCH_NOMADIK)         += nomadik
> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
> new file mode 100644
> index 0000000..6dbb74f
> --- /dev/null
> +++ b/arch/arm/boot/dts/mtk6589.dtsi
> @@ -0,0 +1,105 @@
> +/*
> + * Copyright (c) 2014 MundoReader S.L.
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <dt-bindings/interrupt-controller/irq.h>
> +#include <dt-bindings/interrupt-controller/arm-gic.h>
> +#include "skeleton.dtsi"
> +
> +/ {
> +       compatible = "mediatek,mt6589";

Please document this compatible property.

> +       interrupt-parent = <&gic>;
> +
> +       cpus {
> +               #address-cells = <1>;
> +               #size-cells = <0>;
> +
> +               cpu@0 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x0>;
> +               };
> +               cpu@1 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x1>;
> +               };
> +               cpu@2 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x2>;
> +               };
> +               cpu@3 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x3>;
> +               };
> +
> +       };
> +
> +       clocks {
> +               #address-cells = <1>;
> +               #size-cells = <1>;
> +               ranges;
> +
> +               system_clk: system_clk {
> +                       compatible = "fixed-clock";
> +                       clock-frequency = <13000000>;
> +                       #clock-cells = <0>;
> +                       clock-output-names = "system_clk";
> +               };
> +
> +               rtc_clk: rtc_clk {
> +                       compatible = "fixed-clock";
> +                       clock-frequency = <32000>;
> +                       #clock-cells = <0>;
> +                       clock-output-names = "rtc_clk";
> +               };
> +       };
> +
> +       soc {
> +               #address-cells = <1>;
> +               #size-cells = <1>;
> +               compatible = "simple-bus";
> +               clock-ranges;
> +               ranges;
> +
> +               gic: interrupt-controller@10212000 {
> +                       compatible = "arm,cortex-a9-gic";

A7 is GICv2. You are missing the various virtualization extension properties.

> +                       interrupt-controller;
> +                       #interrupt-cells = <3>;
> +                       reg = <0x10211000 0x1000>,
> +                             <0x10212000 0x1000>;
> +               };
> +
> +               L2: l2-cache-controller@1020e000 {
> +                       compatible = "arm,pl310-cache";

Really? An A7 normally has a built-in L2, not a PL310.

> +                       reg = <0x1020e000 0x1000>;
> +                       cache-unified;
> +                       cache-level = <2>;
> +               };
> +
> +               timer: timer@10008000 {
> +                       compatible = "mediatek,mtk6589-timer";
> +                       reg = <0x10008000 0x80>;
> +                       interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
> +                       clocks = <&system_clk>, <&rtc_clk>;
> +                       clock-names = "sys_clk", "rtc_clk";
> +               };
> +       };
> +};
> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> new file mode 100644
> index 0000000..c0139ca
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/Kconfig
> @@ -0,0 +1,14 @@
> +config ARCH_MEDIATEK
> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
> +       select ARCH_REQUIRE_GPIOLIB

Then where is your GPIO driver?

> +       select ARM_GIC
> +       select CACHE_L2X0
> +       select HAVE_ARM_TWD if LOCAL_TIMERS
> +       select HAVE_SMP

Not needed now (going into 3.15).

> +       select LOCAL_TIMERS if SMP
> +       select COMMON_CLK

ditto

> +       select GENERIC_CLOCKEVENTS

ditto

> +       select MTK_TIMER
> +       select CLKSRC_MMIO

This belongs with your timer kconfig

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-09 21:50     ` Rob Herring
  0 siblings, 0 replies; 74+ messages in thread
From: Rob Herring @ 2014-04-09 21:50 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: linux-kernel, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Randy Dunlap, Russell King - ARM Linux,
	Daniel Lezcano, Thomas Gleixner, Thierry Reding,
	Florian Vaussard, Jonathan Cameron, Jason Cooper, Andrew Lunn,
	Silvio F, heiko.stuebner, Olof Johansson, Sebastian Hesselbarth,
	devicetree, linux-doc

On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
> This adds a generic devicetree board file and a dtsi for boards
> based on the MT6589 SoCs from Mediatek.
>
> Apart from the generic parts (gic, clocks) the only component
> currently supported are the timers.
>
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>  arch/arm/Kconfig                                   |    2 +
>  arch/arm/Makefile                                  |    1 +
>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++

Please add an actual board so your dts file can actually be built.

>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>  arch/arm/mach-mediatek/Makefile                    |    1 +
>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>  7 files changed, 164 insertions(+)
>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>  create mode 100644 arch/arm/mach-mediatek/Makefile
>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
>
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index 0f01c9b..af48801 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -67,6 +67,7 @@ linux Linux-specific binding
>  lsi    LSI Corp. (LSI Logic)
>  marvell        Marvell Technology Group Ltd.
>  maxim  Maxim Integrated Products
> +mediatek       MediaTek Inc.
>  microchip      Microchip Technology Inc.
>  mosaixtech     Mosaix Technologies, Inc.
>  moxa   Moxa
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 5db05f6a..04d46ec 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>
>  source "arch/arm/mach-imx/Kconfig"
>
> +source "arch/arm/mach-mediatek/Kconfig"
> +
>  source "arch/arm/mach-mxs/Kconfig"
>
>  source "arch/arm/mach-netx/Kconfig"
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 41c1931..8ce9774 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)          += msm
>  machine-$(CONFIG_ARCH_MV78XX0)         += mv78xx0
>  machine-$(CONFIG_ARCH_MVEBU)           += mvebu
>  machine-$(CONFIG_ARCH_MXC)             += imx
> +machine-$(CONFIG_ARCH_MEDIATEK)                += mediatek
>  machine-$(CONFIG_ARCH_MXS)             += mxs
>  machine-$(CONFIG_ARCH_NETX)            += netx
>  machine-$(CONFIG_ARCH_NOMADIK)         += nomadik
> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
> new file mode 100644
> index 0000000..6dbb74f
> --- /dev/null
> +++ b/arch/arm/boot/dts/mtk6589.dtsi
> @@ -0,0 +1,105 @@
> +/*
> + * Copyright (c) 2014 MundoReader S.L.
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <dt-bindings/interrupt-controller/irq.h>
> +#include <dt-bindings/interrupt-controller/arm-gic.h>
> +#include "skeleton.dtsi"
> +
> +/ {
> +       compatible = "mediatek,mt6589";

Please document this compatible property.

> +       interrupt-parent = <&gic>;
> +
> +       cpus {
> +               #address-cells = <1>;
> +               #size-cells = <0>;
> +
> +               cpu@0 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x0>;
> +               };
> +               cpu@1 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x1>;
> +               };
> +               cpu@2 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x2>;
> +               };
> +               cpu@3 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x3>;
> +               };
> +
> +       };
> +
> +       clocks {
> +               #address-cells = <1>;
> +               #size-cells = <1>;
> +               ranges;
> +
> +               system_clk: system_clk {
> +                       compatible = "fixed-clock";
> +                       clock-frequency = <13000000>;
> +                       #clock-cells = <0>;
> +                       clock-output-names = "system_clk";
> +               };
> +
> +               rtc_clk: rtc_clk {
> +                       compatible = "fixed-clock";
> +                       clock-frequency = <32000>;
> +                       #clock-cells = <0>;
> +                       clock-output-names = "rtc_clk";
> +               };
> +       };
> +
> +       soc {
> +               #address-cells = <1>;
> +               #size-cells = <1>;
> +               compatible = "simple-bus";
> +               clock-ranges;
> +               ranges;
> +
> +               gic: interrupt-controller@10212000 {
> +                       compatible = "arm,cortex-a9-gic";

A7 is GICv2. You are missing the various virtualization extension properties.

> +                       interrupt-controller;
> +                       #interrupt-cells = <3>;
> +                       reg = <0x10211000 0x1000>,
> +                             <0x10212000 0x1000>;
> +               };
> +
> +               L2: l2-cache-controller@1020e000 {
> +                       compatible = "arm,pl310-cache";

Really? An A7 normally has a built-in L2, not a PL310.

> +                       reg = <0x1020e000 0x1000>;
> +                       cache-unified;
> +                       cache-level = <2>;
> +               };
> +
> +               timer: timer@10008000 {
> +                       compatible = "mediatek,mtk6589-timer";
> +                       reg = <0x10008000 0x80>;
> +                       interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
> +                       clocks = <&system_clk>, <&rtc_clk>;
> +                       clock-names = "sys_clk", "rtc_clk";
> +               };
> +       };
> +};
> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> new file mode 100644
> index 0000000..c0139ca
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/Kconfig
> @@ -0,0 +1,14 @@
> +config ARCH_MEDIATEK
> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
> +       select ARCH_REQUIRE_GPIOLIB

Then where is your GPIO driver?

> +       select ARM_GIC
> +       select CACHE_L2X0
> +       select HAVE_ARM_TWD if LOCAL_TIMERS
> +       select HAVE_SMP

Not needed now (going into 3.15).

> +       select LOCAL_TIMERS if SMP
> +       select COMMON_CLK

ditto

> +       select GENERIC_CLOCKEVENTS

ditto

> +       select MTK_TIMER
> +       select CLKSRC_MMIO

This belongs with your timer kconfig

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-09 21:50     ` Rob Herring
  0 siblings, 0 replies; 74+ messages in thread
From: Rob Herring @ 2014-04-09 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
> This adds a generic devicetree board file and a dtsi for boards
> based on the MT6589 SoCs from Mediatek.
>
> Apart from the generic parts (gic, clocks) the only component
> currently supported are the timers.
>
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> ---
>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>  arch/arm/Kconfig                                   |    2 +
>  arch/arm/Makefile                                  |    1 +
>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++

Please add an actual board so your dts file can actually be built.

>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>  arch/arm/mach-mediatek/Makefile                    |    1 +
>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>  7 files changed, 164 insertions(+)
>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>  create mode 100644 arch/arm/mach-mediatek/Makefile
>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
>
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index 0f01c9b..af48801 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -67,6 +67,7 @@ linux Linux-specific binding
>  lsi    LSI Corp. (LSI Logic)
>  marvell        Marvell Technology Group Ltd.
>  maxim  Maxim Integrated Products
> +mediatek       MediaTek Inc.
>  microchip      Microchip Technology Inc.
>  mosaixtech     Mosaix Technologies, Inc.
>  moxa   Moxa
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 5db05f6a..04d46ec 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>
>  source "arch/arm/mach-imx/Kconfig"
>
> +source "arch/arm/mach-mediatek/Kconfig"
> +
>  source "arch/arm/mach-mxs/Kconfig"
>
>  source "arch/arm/mach-netx/Kconfig"
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 41c1931..8ce9774 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)          += msm
>  machine-$(CONFIG_ARCH_MV78XX0)         += mv78xx0
>  machine-$(CONFIG_ARCH_MVEBU)           += mvebu
>  machine-$(CONFIG_ARCH_MXC)             += imx
> +machine-$(CONFIG_ARCH_MEDIATEK)                += mediatek
>  machine-$(CONFIG_ARCH_MXS)             += mxs
>  machine-$(CONFIG_ARCH_NETX)            += netx
>  machine-$(CONFIG_ARCH_NOMADIK)         += nomadik
> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
> new file mode 100644
> index 0000000..6dbb74f
> --- /dev/null
> +++ b/arch/arm/boot/dts/mtk6589.dtsi
> @@ -0,0 +1,105 @@
> +/*
> + * Copyright (c) 2014 MundoReader S.L.
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <dt-bindings/interrupt-controller/irq.h>
> +#include <dt-bindings/interrupt-controller/arm-gic.h>
> +#include "skeleton.dtsi"
> +
> +/ {
> +       compatible = "mediatek,mt6589";

Please document this compatible property.

> +       interrupt-parent = <&gic>;
> +
> +       cpus {
> +               #address-cells = <1>;
> +               #size-cells = <0>;
> +
> +               cpu at 0 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x0>;
> +               };
> +               cpu at 1 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x1>;
> +               };
> +               cpu at 2 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x2>;
> +               };
> +               cpu at 3 {
> +                       device_type = "cpu";
> +                       compatible = "arm,cortex-a7";
> +                       next-level-cache = <&L2>;
> +                       reg = <0x3>;
> +               };
> +
> +       };
> +
> +       clocks {
> +               #address-cells = <1>;
> +               #size-cells = <1>;
> +               ranges;
> +
> +               system_clk: system_clk {
> +                       compatible = "fixed-clock";
> +                       clock-frequency = <13000000>;
> +                       #clock-cells = <0>;
> +                       clock-output-names = "system_clk";
> +               };
> +
> +               rtc_clk: rtc_clk {
> +                       compatible = "fixed-clock";
> +                       clock-frequency = <32000>;
> +                       #clock-cells = <0>;
> +                       clock-output-names = "rtc_clk";
> +               };
> +       };
> +
> +       soc {
> +               #address-cells = <1>;
> +               #size-cells = <1>;
> +               compatible = "simple-bus";
> +               clock-ranges;
> +               ranges;
> +
> +               gic: interrupt-controller at 10212000 {
> +                       compatible = "arm,cortex-a9-gic";

A7 is GICv2. You are missing the various virtualization extension properties.

> +                       interrupt-controller;
> +                       #interrupt-cells = <3>;
> +                       reg = <0x10211000 0x1000>,
> +                             <0x10212000 0x1000>;
> +               };
> +
> +               L2: l2-cache-controller at 1020e000 {
> +                       compatible = "arm,pl310-cache";

Really? An A7 normally has a built-in L2, not a PL310.

> +                       reg = <0x1020e000 0x1000>;
> +                       cache-unified;
> +                       cache-level = <2>;
> +               };
> +
> +               timer: timer at 10008000 {
> +                       compatible = "mediatek,mtk6589-timer";
> +                       reg = <0x10008000 0x80>;
> +                       interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
> +                       clocks = <&system_clk>, <&rtc_clk>;
> +                       clock-names = "sys_clk", "rtc_clk";
> +               };
> +       };
> +};
> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> new file mode 100644
> index 0000000..c0139ca
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/Kconfig
> @@ -0,0 +1,14 @@
> +config ARCH_MEDIATEK
> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
> +       select ARCH_REQUIRE_GPIOLIB

Then where is your GPIO driver?

> +       select ARM_GIC
> +       select CACHE_L2X0
> +       select HAVE_ARM_TWD if LOCAL_TIMERS
> +       select HAVE_SMP

Not needed now (going into 3.15).

> +       select LOCAL_TIMERS if SMP
> +       select COMMON_CLK

ditto

> +       select GENERIC_CLOCKEVENTS

ditto

> +       select MTK_TIMER
> +       select CLKSRC_MMIO

This belongs with your timer kconfig

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

* Re: [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 21:52     ` Olof Johansson
  0 siblings, 0 replies; 74+ messages in thread
From: Olof Johansson @ 2014-04-09 21:52 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: linux-kernel, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Randy Dunlap, Russell King - ARM Linux,
	Daniel Lezcano, Thomas Gleixner, Thierry Reding,
	florian.vaussard, Jonathan Cameron, Jason Cooper, Andrew Lunn,
	silvio.fricke, heiko.stuebner, Sebastian Hesselbarth, devicetree,
	linux-doc, linux-arm-kernel

Hi,

On Wed, Apr 9, 2014 at 12:45 PM, Matthias Brugger
<matthias.bgg@gmail.com> wrote:
> This patch adds a clock source and clock event for the timer found
> on the Mediatek SoCs.
>
> The Mediatek General Porpose Timer block provides five 32 bit timers and
> one 64 bit timer.
>
> Two 32 bit timers are used:
> TIMER1: clock events supporting periodic and oneshot events
> TIMER2: clock source configured as a free running counter
>
> The General Porpose Timer block can be run with two clocks. A 13 MHz system
> clock and the RTC clock running at 32 KHz. This implementation uses the system
> clock.

Hm, are you planning on using these on the Cortex-A7-based and newer
SoCs? On those, the arm generic timers should be available, and you
might be better off just using those there.

Of course, you'll still need these for the A9-based platforms, so the
driver might very well be needed anyway. Some of the earlier patches
seem to be for A7-based systems so I'm not sure what you're primarily
working on here. :)


-Olof

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

* Re: [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 21:52     ` Olof Johansson
  0 siblings, 0 replies; 74+ messages in thread
From: Olof Johansson @ 2014-04-09 21:52 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Randy Dunlap,
	Russell King - ARM Linux, Daniel Lezcano, Thomas Gleixner,
	Thierry Reding, florian.vaussard-p8DiymsW2f8, Jonathan Cameron,
	Jason Cooper, Andrew Lunn, silvio.fricke-Re5JQEeQqe8AvxtiuMwx3w,
	heiko.stuebner-K3U4GQvHnyU, Sebastian Hesselbarth,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org

Hi,

On Wed, Apr 9, 2014 at 12:45 PM, Matthias Brugger
<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> This patch adds a clock source and clock event for the timer found
> on the Mediatek SoCs.
>
> The Mediatek General Porpose Timer block provides five 32 bit timers and
> one 64 bit timer.
>
> Two 32 bit timers are used:
> TIMER1: clock events supporting periodic and oneshot events
> TIMER2: clock source configured as a free running counter
>
> The General Porpose Timer block can be run with two clocks. A 13 MHz system
> clock and the RTC clock running at 32 KHz. This implementation uses the system
> clock.

Hm, are you planning on using these on the Cortex-A7-based and newer
SoCs? On those, the arm generic timers should be available, and you
might be better off just using those there.

Of course, you'll still need these for the A9-based platforms, so the
driver might very well be needed anyway. Some of the earlier patches
seem to be for A7-based systems so I'm not sure what you're primarily
working on here. :)


-Olof
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-09 21:52     ` Olof Johansson
  0 siblings, 0 replies; 74+ messages in thread
From: Olof Johansson @ 2014-04-09 21:52 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Wed, Apr 9, 2014 at 12:45 PM, Matthias Brugger
<matthias.bgg@gmail.com> wrote:
> This patch adds a clock source and clock event for the timer found
> on the Mediatek SoCs.
>
> The Mediatek General Porpose Timer block provides five 32 bit timers and
> one 64 bit timer.
>
> Two 32 bit timers are used:
> TIMER1: clock events supporting periodic and oneshot events
> TIMER2: clock source configured as a free running counter
>
> The General Porpose Timer block can be run with two clocks. A 13 MHz system
> clock and the RTC clock running at 32 KHz. This implementation uses the system
> clock.

Hm, are you planning on using these on the Cortex-A7-based and newer
SoCs? On those, the arm generic timers should be available, and you
might be better off just using those there.

Of course, you'll still need these for the A9-based platforms, so the
driver might very well be needed anyway. Some of the earlier patches
seem to be for A7-based systems so I'm not sure what you're primarily
working on here. :)


-Olof

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-09 19:45   ` Matthias Brugger
  (?)
@ 2014-04-10  7:36     ` Arnd Bergmann
  -1 siblings, 0 replies; 74+ messages in thread
From: Arnd Bergmann @ 2014-04-10  7:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Matthias Brugger, linux-kernel, mark.rutland, andrew, linux-doc,
	thierry.reding, heiko.stuebner, linux, daniel.lezcano,
	florian.vaussard, sebastian.hesselbarth, devicetree, jason,
	pawel.moll, ijc+devicetree, robh+dt, tglx, rdunlap,
	silvio.fricke, galak, olof, jic23, rmk+kernel

On Wednesday 09 April 2014 21:45:35 Matthias Brugger wrote:
> This adds a generic devicetree board file and a dtsi for boards
> based on the MT6589 SoCs from Mediatek.
> 
> Apart from the generic parts (gic, clocks) the only component
> currently supported are the timers.
> 
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>

Hi Matthias,

First of all, I'm really glad to see this get started, thanks for looking
into these!

Do you know how similar the MT6589 is to the later chips like MT65x2
and MT6588? What are the on-chip devices like, is it mostly licensed
IP blocks from designware and others that we already have drivers for,
or all new drivers?

> +#include <asm/hardware/cache-l2x0.h>
> +
> +static void __init mediatek_dt_init(void)
> +{
> +	l2x0_of_init(0, ~0);
> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +}

I hope that with all the cleanup work that Russell has done in the
past few weeks, we can manage to kill off the call to l2x0_of_init()
here and have it done by core architecture code instead. That would
let you have an empty machine file, unless you have other things you
will need to add in the future.

	Arnd

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  7:36     ` Arnd Bergmann
  0 siblings, 0 replies; 74+ messages in thread
From: Arnd Bergmann @ 2014-04-10  7:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: mark.rutland, andrew, linux-doc, thierry.reding, heiko.stuebner,
	linux, daniel.lezcano, rmk+kernel, florian.vaussard,
	sebastian.hesselbarth, devicetree, jason, pawel.moll,
	ijc+devicetree, robh+dt, Matthias Brugger, tglx, rdunlap,
	linux-kernel, silvio.fricke, galak, olof, jic23

On Wednesday 09 April 2014 21:45:35 Matthias Brugger wrote:
> This adds a generic devicetree board file and a dtsi for boards
> based on the MT6589 SoCs from Mediatek.
> 
> Apart from the generic parts (gic, clocks) the only component
> currently supported are the timers.
> 
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>

Hi Matthias,

First of all, I'm really glad to see this get started, thanks for looking
into these!

Do you know how similar the MT6589 is to the later chips like MT65x2
and MT6588? What are the on-chip devices like, is it mostly licensed
IP blocks from designware and others that we already have drivers for,
or all new drivers?

> +#include <asm/hardware/cache-l2x0.h>
> +
> +static void __init mediatek_dt_init(void)
> +{
> +	l2x0_of_init(0, ~0);
> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +}

I hope that with all the cleanup work that Russell has done in the
past few weeks, we can manage to kill off the call to l2x0_of_init()
here and have it done by core architecture code instead. That would
let you have an empty machine file, unless you have other things you
will need to add in the future.

	Arnd

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  7:36     ` Arnd Bergmann
  0 siblings, 0 replies; 74+ messages in thread
From: Arnd Bergmann @ 2014-04-10  7:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Wednesday 09 April 2014 21:45:35 Matthias Brugger wrote:
> This adds a generic devicetree board file and a dtsi for boards
> based on the MT6589 SoCs from Mediatek.
> 
> Apart from the generic parts (gic, clocks) the only component
> currently supported are the timers.
> 
> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>

Hi Matthias,

First of all, I'm really glad to see this get started, thanks for looking
into these!

Do you know how similar the MT6589 is to the later chips like MT65x2
and MT6588? What are the on-chip devices like, is it mostly licensed
IP blocks from designware and others that we already have drivers for,
or all new drivers?

> +#include <asm/hardware/cache-l2x0.h>
> +
> +static void __init mediatek_dt_init(void)
> +{
> +	l2x0_of_init(0, ~0);
> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +}

I hope that with all the cleanup work that Russell has done in the
past few weeks, we can manage to kill off the call to l2x0_of_init()
here and have it done by core architecture code instead. That would
let you have an empty machine file, unless you have other things you
will need to add in the future.

	Arnd

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

* Re: [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589
@ 2014-04-10  8:22       ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-10  8:22 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Randy Dunlap, Russell King - ARM Linux,
	Daniel Lezcano, Thomas Gleixner, Thierry Reding,
	Florian Vaussard, Jonathan Cameron, Jason Cooper, Andrew Lunn,
	Silvio F, Heiko Stübner, Olof Johansson,
	Sebastian Hesselbarth, devicetree, linux-doc, linux-arm-kernel

2014-04-09 23:39 GMT+02:00 Rob Herring <robherring2@gmail.com>:
> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>> ---
>>  arch/arm/Kconfig.debug            |   49 +++++++++++++++++++++++++++++++++++--
>>  arch/arm/include/debug/mediatek.S |   38 ++++++++++++++++++++++++++++
>>  2 files changed, 85 insertions(+), 2 deletions(-)
>>  create mode 100644 arch/arm/include/debug/mediatek.S
>>
>> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
>> index 4a2fc0b..dc51495 100644
>> --- a/arch/arm/Kconfig.debug
>> +++ b/arch/arm/Kconfig.debug
>> @@ -797,6 +797,38 @@ choice
>>                   Say Y here if you want kernel low-level debugging support
>>                   on Ux500 based platforms.
>>
>> +       config DEBUG_MTK6589_UART0
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART0"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>> +       config DEBUG_MTK6589_UART1
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART1"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>> +       config DEBUG_MTK6589_UART2
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART2"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>> +       config DEBUG_MTK6589_UART3
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART3"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>
> Do you really need all uarts defined? Only define what you have boards using.
>
> Also, you have no uarts defined in your dts. Please add them there
> (and any necessary serial driver) before adding debug functionality.
> Otherwise, you can't actually boot a multi-platform kernel with this
> series.

Up to now, there no serial driver exists. Should I skip this patch and
re-submit it when the serial driver is integrated?


-- 
motzblog.wordpress.com

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

* Re: [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589
@ 2014-04-10  8:22       ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-10  8:22 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Randy Dunlap,
	Russell King - ARM Linux, Daniel Lezcano, Thomas Gleixner,
	Thierry Reding, Florian Vaussard, Jonathan Cameron, Jason Cooper,
	Andrew Lunn, Silvio F, Heiko Stübner, Olof Johansson,
	Sebastian Hesselbarth, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TbrhsbdSgBK9A

2014-04-09 23:39 GMT+02:00 Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> Signed-off-by: Matthias Brugger <matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>>  arch/arm/Kconfig.debug            |   49 +++++++++++++++++++++++++++++++++++--
>>  arch/arm/include/debug/mediatek.S |   38 ++++++++++++++++++++++++++++
>>  2 files changed, 85 insertions(+), 2 deletions(-)
>>  create mode 100644 arch/arm/include/debug/mediatek.S
>>
>> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
>> index 4a2fc0b..dc51495 100644
>> --- a/arch/arm/Kconfig.debug
>> +++ b/arch/arm/Kconfig.debug
>> @@ -797,6 +797,38 @@ choice
>>                   Say Y here if you want kernel low-level debugging support
>>                   on Ux500 based platforms.
>>
>> +       config DEBUG_MTK6589_UART0
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART0"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>> +       config DEBUG_MTK6589_UART1
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART1"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>> +       config DEBUG_MTK6589_UART2
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART2"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>> +       config DEBUG_MTK6589_UART3
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART3"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>
> Do you really need all uarts defined? Only define what you have boards using.
>
> Also, you have no uarts defined in your dts. Please add them there
> (and any necessary serial driver) before adding debug functionality.
> Otherwise, you can't actually boot a multi-platform kernel with this
> series.

Up to now, there no serial driver exists. Should I skip this patch and
re-submit it when the serial driver is integrated?


-- 
motzblog.wordpress.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589
@ 2014-04-10  8:22       ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-10  8:22 UTC (permalink / raw)
  To: linux-arm-kernel

2014-04-09 23:39 GMT+02:00 Rob Herring <robherring2@gmail.com>:
> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>> ---
>>  arch/arm/Kconfig.debug            |   49 +++++++++++++++++++++++++++++++++++--
>>  arch/arm/include/debug/mediatek.S |   38 ++++++++++++++++++++++++++++
>>  2 files changed, 85 insertions(+), 2 deletions(-)
>>  create mode 100644 arch/arm/include/debug/mediatek.S
>>
>> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
>> index 4a2fc0b..dc51495 100644
>> --- a/arch/arm/Kconfig.debug
>> +++ b/arch/arm/Kconfig.debug
>> @@ -797,6 +797,38 @@ choice
>>                   Say Y here if you want kernel low-level debugging support
>>                   on Ux500 based platforms.
>>
>> +       config DEBUG_MTK6589_UART0
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART0"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>> +       config DEBUG_MTK6589_UART1
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART1"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>> +       config DEBUG_MTK6589_UART2
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART2"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>> +       config DEBUG_MTK6589_UART3
>> +               depends on ARCH_MEDIATEK
>> +               bool "Mediatek mt6589 UART3"
>> +               select DEBUG_UART_MEDIATEK
>> +               help
>> +                 Say Y here if you want kernel low-level debugging support
>> +                 on Mediatek mt6589 based platforms.
>> +
>
> Do you really need all uarts defined? Only define what you have boards using.
>
> Also, you have no uarts defined in your dts. Please add them there
> (and any necessary serial driver) before adding debug functionality.
> Otherwise, you can't actually boot a multi-platform kernel with this
> series.

Up to now, there no serial driver exists. Should I skip this patch and
re-submit it when the serial driver is integrated?


-- 
motzblog.wordpress.com

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-09 20:26     ` Gregory CLEMENT
  (?)
@ 2014-04-10  8:29       ` Matthias Brugger
  -1 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-10  8:29 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: linux-kernel, Mark Rutland, Andrew Lunn, linux-doc,
	Thierry Reding, Heiko Stübner, Russell King, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, Silvio F,
	Kumar Gala, Olof Johansson, Jonathan Cameron

2014-04-09 22:26 GMT+02:00 Gregory CLEMENT <gregory.clement@free-electrons.com>:
> Hi Matthias,
>
> On 09/04/2014 19:45, Matthias Brugger wrote:
>> This adds a generic devicetree board file and a dtsi for boards
>> based on the MT6589 SoCs from Mediatek.
>>
>> Apart from the generic parts (gic, clocks) the only component
>> currently supported are the timers.
>>
>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>> ---
>>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>>  arch/arm/Kconfig                                   |    2 +
>>  arch/arm/Makefile                                  |    1 +
>>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++
>>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>>  arch/arm/mach-mediatek/Makefile                    |    1 +
>>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>>  7 files changed, 164 insertions(+)
>>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>>  create mode 100644 arch/arm/mach-mediatek/Makefile
>>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
>>
>> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
>> index 0f01c9b..af48801 100644
>> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
>> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
>> @@ -67,6 +67,7 @@ linux       Linux-specific binding
>>  lsi  LSI Corp. (LSI Logic)
>>  marvell      Marvell Technology Group Ltd.
>>  maxim        Maxim Integrated Products
>> +mediatek     MediaTek Inc.
>>  microchip    Microchip Technology Inc.
>>  mosaixtech   Mosaix Technologies, Inc.
>>  moxa Moxa
>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> index 5db05f6a..04d46ec 100644
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>>
>>  source "arch/arm/mach-imx/Kconfig"
>>
>> +source "arch/arm/mach-mediatek/Kconfig"
>> +
>>  source "arch/arm/mach-mxs/Kconfig"
>>
>>  source "arch/arm/mach-netx/Kconfig"
>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>> index 41c1931..8ce9774 100644
>> --- a/arch/arm/Makefile
>> +++ b/arch/arm/Makefile
>> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)                += msm
>>  machine-$(CONFIG_ARCH_MV78XX0)               += mv78xx0
>>  machine-$(CONFIG_ARCH_MVEBU)         += mvebu
>>  machine-$(CONFIG_ARCH_MXC)           += imx
>> +machine-$(CONFIG_ARCH_MEDIATEK)              += mediatek
>>  machine-$(CONFIG_ARCH_MXS)           += mxs
>>  machine-$(CONFIG_ARCH_NETX)          += netx
>>  machine-$(CONFIG_ARCH_NOMADIK)               += nomadik
>> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
>> new file mode 100644
>> index 0000000..6dbb74f
>> --- /dev/null
>> +++ b/arch/arm/boot/dts/mtk6589.dtsi
>> @@ -0,0 +1,105 @@
>> +/*
>> + * Copyright (c) 2014 MundoReader S.L.
>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <dt-bindings/interrupt-controller/irq.h>
>> +#include <dt-bindings/interrupt-controller/arm-gic.h>
>> +#include "skeleton.dtsi"
>> +
>> +/ {
>> +     compatible = "mediatek,mt6589";
>> +     interrupt-parent = <&gic>;
>> +
>> +     cpus {
>> +             #address-cells = <1>;
>> +             #size-cells = <0>;
>> +
>> +             cpu@0 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x0>;
>> +             };
>> +             cpu@1 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x1>;
>> +             };
>> +             cpu@2 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x2>;
>> +             };
>> +             cpu@3 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x3>;
>> +             };
>> +
>> +     };
>> +
>> +     clocks {
>> +             #address-cells = <1>;
>> +             #size-cells = <1>;
>> +             ranges;
>> +
>> +             system_clk: system_clk {
>> +                     compatible = "fixed-clock";
>> +                     clock-frequency = <13000000>;
>> +                     #clock-cells = <0>;
>> +                     clock-output-names = "system_clk";
>> +             };
>
> Is it really a fixed clock without any parent, or do you
> declare it as a fixed clock because you don't have any clock
> common framework support yet?

I don't have any common clock framework support yet.

>
>> +
>> +             rtc_clk: rtc_clk {
>> +                     compatible = "fixed-clock";
>> +                     clock-frequency = <32000>;
>> +                     #clock-cells = <0>;
>> +                     clock-output-names = "rtc_clk";
>> +             };
>> +     };
>> +
>> +     soc {
>> +             #address-cells = <1>;
>> +             #size-cells = <1>;
>> +             compatible = "simple-bus";
>> +             clock-ranges;
>> +             ranges;
>> +
>> +             gic: interrupt-controller@10212000 {
>> +                     compatible = "arm,cortex-a9-gic";
>> +                     interrupt-controller;
>> +                     #interrupt-cells = <3>;
>> +                     reg = <0x10211000 0x1000>,
>> +                           <0x10212000 0x1000>;
>> +             };
>> +
>> +             L2: l2-cache-controller@1020e000 {
>> +                     compatible = "arm,pl310-cache";
>> +                     reg = <0x1020e000 0x1000>;
>> +                     cache-unified;
>> +                     cache-level = <2>;
>> +             };
>> +
>> +             timer: timer@10008000 {
>> +                     compatible = "mediatek,mtk6589-timer";
>> +                     reg = <0x10008000 0x80>;
>> +                     interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
>> +                     clocks = <&system_clk>, <&rtc_clk>;
>> +                     clock-names = "sys_clk", "rtc_clk";
>> +             };
>> +     };
>> +};
>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>> new file mode 100644
>> index 0000000..c0139ca
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/Kconfig
>> @@ -0,0 +1,14 @@
>> +config ARCH_MEDIATEK
>> +     bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>> +     select ARCH_REQUIRE_GPIOLIB
>> +     select ARM_GIC
>> +     select CACHE_L2X0
>> +     select HAVE_ARM_TWD if LOCAL_TIMERS
>
> LOCAL_TIMERS no longer exist
>
>> +     select HAVE_SMP
>> +     select LOCAL_TIMERS if SMP
> ditto
>
> so what about this instead:
>
>         select HAVE_ARM_TWD if SMP
>
>
> The rest of this patch looks good.
>
> Thanks,
>
> Gregory
>
>> +     select COMMON_CLK
>> +     select GENERIC_CLOCKEVENTS
>> +     select MTK_TIMER
>> +     select CLKSRC_MMIO
>> +     help
>> +       Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
>> diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
>> new file mode 100644
>> index 0000000..43e619f
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/Makefile
>> @@ -0,0 +1 @@
>> +obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
>> diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
>> new file mode 100644
>> index 0000000..f630403
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/mediatek.c
>> @@ -0,0 +1,40 @@
>> +/*
>> + * Device Tree support for Mediatek SoCs
>> + *
>> + * Copyright (c) 2014 MundoReader S.L.
>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/init.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/irqchip.h>
>> +#include <asm/mach/arch.h>
>> +#include <asm/mach/map.h>
>> +#include <asm/hardware/cache-l2x0.h>
>> +
>> +static void __init mediatek_dt_init(void)
>> +{
>> +     l2x0_of_init(0, ~0);
>> +     of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>> +}
>> +
>> +static const char * const mediatek_board_dt_compat[] = {
>> +     "mediatek,mt6589",
>> +     NULL,
>> +};
>> +
>> +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
>> +     .init_machine   = mediatek_dt_init,
>> +     .dt_compat      = mediatek_board_dt_compat,
>> +MACHINE_END
>>
>
>
> --
> Gregory Clement, Free Electrons
> Kernel, drivers, real-time and embedded Linux
> development, consulting, training and support.
> http://free-electrons.com



-- 
motzblog.wordpress.com

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  8:29       ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-10  8:29 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: linux-kernel, Mark Rutland, Andrew Lunn, linux-doc,
	Thierry Reding, Heiko Stübner, Russell King, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, Silvio F

2014-04-09 22:26 GMT+02:00 Gregory CLEMENT <gregory.clement@free-electrons.com>:
> Hi Matthias,
>
> On 09/04/2014 19:45, Matthias Brugger wrote:
>> This adds a generic devicetree board file and a dtsi for boards
>> based on the MT6589 SoCs from Mediatek.
>>
>> Apart from the generic parts (gic, clocks) the only component
>> currently supported are the timers.
>>
>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>> ---
>>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>>  arch/arm/Kconfig                                   |    2 +
>>  arch/arm/Makefile                                  |    1 +
>>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++
>>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>>  arch/arm/mach-mediatek/Makefile                    |    1 +
>>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>>  7 files changed, 164 insertions(+)
>>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>>  create mode 100644 arch/arm/mach-mediatek/Makefile
>>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
>>
>> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
>> index 0f01c9b..af48801 100644
>> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
>> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
>> @@ -67,6 +67,7 @@ linux       Linux-specific binding
>>  lsi  LSI Corp. (LSI Logic)
>>  marvell      Marvell Technology Group Ltd.
>>  maxim        Maxim Integrated Products
>> +mediatek     MediaTek Inc.
>>  microchip    Microchip Technology Inc.
>>  mosaixtech   Mosaix Technologies, Inc.
>>  moxa Moxa
>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> index 5db05f6a..04d46ec 100644
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>>
>>  source "arch/arm/mach-imx/Kconfig"
>>
>> +source "arch/arm/mach-mediatek/Kconfig"
>> +
>>  source "arch/arm/mach-mxs/Kconfig"
>>
>>  source "arch/arm/mach-netx/Kconfig"
>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>> index 41c1931..8ce9774 100644
>> --- a/arch/arm/Makefile
>> +++ b/arch/arm/Makefile
>> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)                += msm
>>  machine-$(CONFIG_ARCH_MV78XX0)               += mv78xx0
>>  machine-$(CONFIG_ARCH_MVEBU)         += mvebu
>>  machine-$(CONFIG_ARCH_MXC)           += imx
>> +machine-$(CONFIG_ARCH_MEDIATEK)              += mediatek
>>  machine-$(CONFIG_ARCH_MXS)           += mxs
>>  machine-$(CONFIG_ARCH_NETX)          += netx
>>  machine-$(CONFIG_ARCH_NOMADIK)               += nomadik
>> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
>> new file mode 100644
>> index 0000000..6dbb74f
>> --- /dev/null
>> +++ b/arch/arm/boot/dts/mtk6589.dtsi
>> @@ -0,0 +1,105 @@
>> +/*
>> + * Copyright (c) 2014 MundoReader S.L.
>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <dt-bindings/interrupt-controller/irq.h>
>> +#include <dt-bindings/interrupt-controller/arm-gic.h>
>> +#include "skeleton.dtsi"
>> +
>> +/ {
>> +     compatible = "mediatek,mt6589";
>> +     interrupt-parent = <&gic>;
>> +
>> +     cpus {
>> +             #address-cells = <1>;
>> +             #size-cells = <0>;
>> +
>> +             cpu@0 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x0>;
>> +             };
>> +             cpu@1 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x1>;
>> +             };
>> +             cpu@2 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x2>;
>> +             };
>> +             cpu@3 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x3>;
>> +             };
>> +
>> +     };
>> +
>> +     clocks {
>> +             #address-cells = <1>;
>> +             #size-cells = <1>;
>> +             ranges;
>> +
>> +             system_clk: system_clk {
>> +                     compatible = "fixed-clock";
>> +                     clock-frequency = <13000000>;
>> +                     #clock-cells = <0>;
>> +                     clock-output-names = "system_clk";
>> +             };
>
> Is it really a fixed clock without any parent, or do you
> declare it as a fixed clock because you don't have any clock
> common framework support yet?

I don't have any common clock framework support yet.

>
>> +
>> +             rtc_clk: rtc_clk {
>> +                     compatible = "fixed-clock";
>> +                     clock-frequency = <32000>;
>> +                     #clock-cells = <0>;
>> +                     clock-output-names = "rtc_clk";
>> +             };
>> +     };
>> +
>> +     soc {
>> +             #address-cells = <1>;
>> +             #size-cells = <1>;
>> +             compatible = "simple-bus";
>> +             clock-ranges;
>> +             ranges;
>> +
>> +             gic: interrupt-controller@10212000 {
>> +                     compatible = "arm,cortex-a9-gic";
>> +                     interrupt-controller;
>> +                     #interrupt-cells = <3>;
>> +                     reg = <0x10211000 0x1000>,
>> +                           <0x10212000 0x1000>;
>> +             };
>> +
>> +             L2: l2-cache-controller@1020e000 {
>> +                     compatible = "arm,pl310-cache";
>> +                     reg = <0x1020e000 0x1000>;
>> +                     cache-unified;
>> +                     cache-level = <2>;
>> +             };
>> +
>> +             timer: timer@10008000 {
>> +                     compatible = "mediatek,mtk6589-timer";
>> +                     reg = <0x10008000 0x80>;
>> +                     interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
>> +                     clocks = <&system_clk>, <&rtc_clk>;
>> +                     clock-names = "sys_clk", "rtc_clk";
>> +             };
>> +     };
>> +};
>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>> new file mode 100644
>> index 0000000..c0139ca
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/Kconfig
>> @@ -0,0 +1,14 @@
>> +config ARCH_MEDIATEK
>> +     bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>> +     select ARCH_REQUIRE_GPIOLIB
>> +     select ARM_GIC
>> +     select CACHE_L2X0
>> +     select HAVE_ARM_TWD if LOCAL_TIMERS
>
> LOCAL_TIMERS no longer exist
>
>> +     select HAVE_SMP
>> +     select LOCAL_TIMERS if SMP
> ditto
>
> so what about this instead:
>
>         select HAVE_ARM_TWD if SMP
>
>
> The rest of this patch looks good.
>
> Thanks,
>
> Gregory
>
>> +     select COMMON_CLK
>> +     select GENERIC_CLOCKEVENTS
>> +     select MTK_TIMER
>> +     select CLKSRC_MMIO
>> +     help
>> +       Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
>> diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
>> new file mode 100644
>> index 0000000..43e619f
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/Makefile
>> @@ -0,0 +1 @@
>> +obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
>> diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
>> new file mode 100644
>> index 0000000..f630403
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/mediatek.c
>> @@ -0,0 +1,40 @@
>> +/*
>> + * Device Tree support for Mediatek SoCs
>> + *
>> + * Copyright (c) 2014 MundoReader S.L.
>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/init.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/irqchip.h>
>> +#include <asm/mach/arch.h>
>> +#include <asm/mach/map.h>
>> +#include <asm/hardware/cache-l2x0.h>
>> +
>> +static void __init mediatek_dt_init(void)
>> +{
>> +     l2x0_of_init(0, ~0);
>> +     of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>> +}
>> +
>> +static const char * const mediatek_board_dt_compat[] = {
>> +     "mediatek,mt6589",
>> +     NULL,
>> +};
>> +
>> +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
>> +     .init_machine   = mediatek_dt_init,
>> +     .dt_compat      = mediatek_board_dt_compat,
>> +MACHINE_END
>>
>
>
> --
> Gregory Clement, Free Electrons
> Kernel, drivers, real-time and embedded Linux
> development, consulting, training and support.
> http://free-electrons.com



-- 
motzblog.wordpress.com

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  8:29       ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-10  8:29 UTC (permalink / raw)
  To: linux-arm-kernel

2014-04-09 22:26 GMT+02:00 Gregory CLEMENT <gregory.clement@free-electrons.com>:
> Hi Matthias,
>
> On 09/04/2014 19:45, Matthias Brugger wrote:
>> This adds a generic devicetree board file and a dtsi for boards
>> based on the MT6589 SoCs from Mediatek.
>>
>> Apart from the generic parts (gic, clocks) the only component
>> currently supported are the timers.
>>
>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>> ---
>>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>>  arch/arm/Kconfig                                   |    2 +
>>  arch/arm/Makefile                                  |    1 +
>>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++
>>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>>  arch/arm/mach-mediatek/Makefile                    |    1 +
>>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>>  7 files changed, 164 insertions(+)
>>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>>  create mode 100644 arch/arm/mach-mediatek/Makefile
>>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
>>
>> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
>> index 0f01c9b..af48801 100644
>> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
>> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
>> @@ -67,6 +67,7 @@ linux       Linux-specific binding
>>  lsi  LSI Corp. (LSI Logic)
>>  marvell      Marvell Technology Group Ltd.
>>  maxim        Maxim Integrated Products
>> +mediatek     MediaTek Inc.
>>  microchip    Microchip Technology Inc.
>>  mosaixtech   Mosaix Technologies, Inc.
>>  moxa Moxa
>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> index 5db05f6a..04d46ec 100644
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>>
>>  source "arch/arm/mach-imx/Kconfig"
>>
>> +source "arch/arm/mach-mediatek/Kconfig"
>> +
>>  source "arch/arm/mach-mxs/Kconfig"
>>
>>  source "arch/arm/mach-netx/Kconfig"
>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>> index 41c1931..8ce9774 100644
>> --- a/arch/arm/Makefile
>> +++ b/arch/arm/Makefile
>> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)                += msm
>>  machine-$(CONFIG_ARCH_MV78XX0)               += mv78xx0
>>  machine-$(CONFIG_ARCH_MVEBU)         += mvebu
>>  machine-$(CONFIG_ARCH_MXC)           += imx
>> +machine-$(CONFIG_ARCH_MEDIATEK)              += mediatek
>>  machine-$(CONFIG_ARCH_MXS)           += mxs
>>  machine-$(CONFIG_ARCH_NETX)          += netx
>>  machine-$(CONFIG_ARCH_NOMADIK)               += nomadik
>> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
>> new file mode 100644
>> index 0000000..6dbb74f
>> --- /dev/null
>> +++ b/arch/arm/boot/dts/mtk6589.dtsi
>> @@ -0,0 +1,105 @@
>> +/*
>> + * Copyright (c) 2014 MundoReader S.L.
>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <dt-bindings/interrupt-controller/irq.h>
>> +#include <dt-bindings/interrupt-controller/arm-gic.h>
>> +#include "skeleton.dtsi"
>> +
>> +/ {
>> +     compatible = "mediatek,mt6589";
>> +     interrupt-parent = <&gic>;
>> +
>> +     cpus {
>> +             #address-cells = <1>;
>> +             #size-cells = <0>;
>> +
>> +             cpu at 0 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x0>;
>> +             };
>> +             cpu at 1 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x1>;
>> +             };
>> +             cpu at 2 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x2>;
>> +             };
>> +             cpu at 3 {
>> +                     device_type = "cpu";
>> +                     compatible = "arm,cortex-a7";
>> +                     next-level-cache = <&L2>;
>> +                     reg = <0x3>;
>> +             };
>> +
>> +     };
>> +
>> +     clocks {
>> +             #address-cells = <1>;
>> +             #size-cells = <1>;
>> +             ranges;
>> +
>> +             system_clk: system_clk {
>> +                     compatible = "fixed-clock";
>> +                     clock-frequency = <13000000>;
>> +                     #clock-cells = <0>;
>> +                     clock-output-names = "system_clk";
>> +             };
>
> Is it really a fixed clock without any parent, or do you
> declare it as a fixed clock because you don't have any clock
> common framework support yet?

I don't have any common clock framework support yet.

>
>> +
>> +             rtc_clk: rtc_clk {
>> +                     compatible = "fixed-clock";
>> +                     clock-frequency = <32000>;
>> +                     #clock-cells = <0>;
>> +                     clock-output-names = "rtc_clk";
>> +             };
>> +     };
>> +
>> +     soc {
>> +             #address-cells = <1>;
>> +             #size-cells = <1>;
>> +             compatible = "simple-bus";
>> +             clock-ranges;
>> +             ranges;
>> +
>> +             gic: interrupt-controller at 10212000 {
>> +                     compatible = "arm,cortex-a9-gic";
>> +                     interrupt-controller;
>> +                     #interrupt-cells = <3>;
>> +                     reg = <0x10211000 0x1000>,
>> +                           <0x10212000 0x1000>;
>> +             };
>> +
>> +             L2: l2-cache-controller at 1020e000 {
>> +                     compatible = "arm,pl310-cache";
>> +                     reg = <0x1020e000 0x1000>;
>> +                     cache-unified;
>> +                     cache-level = <2>;
>> +             };
>> +
>> +             timer: timer at 10008000 {
>> +                     compatible = "mediatek,mtk6589-timer";
>> +                     reg = <0x10008000 0x80>;
>> +                     interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
>> +                     clocks = <&system_clk>, <&rtc_clk>;
>> +                     clock-names = "sys_clk", "rtc_clk";
>> +             };
>> +     };
>> +};
>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>> new file mode 100644
>> index 0000000..c0139ca
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/Kconfig
>> @@ -0,0 +1,14 @@
>> +config ARCH_MEDIATEK
>> +     bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>> +     select ARCH_REQUIRE_GPIOLIB
>> +     select ARM_GIC
>> +     select CACHE_L2X0
>> +     select HAVE_ARM_TWD if LOCAL_TIMERS
>
> LOCAL_TIMERS no longer exist
>
>> +     select HAVE_SMP
>> +     select LOCAL_TIMERS if SMP
> ditto
>
> so what about this instead:
>
>         select HAVE_ARM_TWD if SMP
>
>
> The rest of this patch looks good.
>
> Thanks,
>
> Gregory
>
>> +     select COMMON_CLK
>> +     select GENERIC_CLOCKEVENTS
>> +     select MTK_TIMER
>> +     select CLKSRC_MMIO
>> +     help
>> +       Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
>> diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
>> new file mode 100644
>> index 0000000..43e619f
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/Makefile
>> @@ -0,0 +1 @@
>> +obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
>> diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
>> new file mode 100644
>> index 0000000..f630403
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/mediatek.c
>> @@ -0,0 +1,40 @@
>> +/*
>> + * Device Tree support for Mediatek SoCs
>> + *
>> + * Copyright (c) 2014 MundoReader S.L.
>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/init.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/irqchip.h>
>> +#include <asm/mach/arch.h>
>> +#include <asm/mach/map.h>
>> +#include <asm/hardware/cache-l2x0.h>
>> +
>> +static void __init mediatek_dt_init(void)
>> +{
>> +     l2x0_of_init(0, ~0);
>> +     of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>> +}
>> +
>> +static const char * const mediatek_board_dt_compat[] = {
>> +     "mediatek,mt6589",
>> +     NULL,
>> +};
>> +
>> +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
>> +     .init_machine   = mediatek_dt_init,
>> +     .dt_compat      = mediatek_board_dt_compat,
>> +MACHINE_END
>>
>
>
> --
> Gregory Clement, Free Electrons
> Kernel, drivers, real-time and embedded Linux
> development, consulting, training and support.
> http://free-electrons.com



-- 
motzblog.wordpress.com

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-10  8:29       ` Matthias Brugger
  (?)
@ 2014-04-10  8:46         ` Gregory CLEMENT
  -1 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-10  8:46 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: linux-kernel, Mark Rutland, Andrew Lunn, linux-doc,
	Thierry Reding, Heiko Stübner, Russell King, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, Silvio F,
	Kumar Gala, Olof Johansson, Jonathan Cameron

On 10/04/2014 08:29, Matthias Brugger wrote:
> 2014-04-09 22:26 GMT+02:00 Gregory CLEMENT <gregory.clement@free-electrons.com>:
>> Hi Matthias,
>>
>> On 09/04/2014 19:45, Matthias Brugger wrote:
>>> This adds a generic devicetree board file and a dtsi for boards
>>> based on the MT6589 SoCs from Mediatek.
>>>
>>> Apart from the generic parts (gic, clocks) the only component
>>> currently supported are the timers.
>>>
>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>> ---
>>>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>>>  arch/arm/Kconfig                                   |    2 +
>>>  arch/arm/Makefile                                  |    1 +
>>>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++
>>>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>>>  arch/arm/mach-mediatek/Makefile                    |    1 +
>>>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>>>  7 files changed, 164 insertions(+)
>>>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>>>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>>>  create mode 100644 arch/arm/mach-mediatek/Makefile
>>>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
>>>
>>> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
>>> index 0f01c9b..af48801 100644
>>> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
>>> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
>>> @@ -67,6 +67,7 @@ linux       Linux-specific binding
>>>  lsi  LSI Corp. (LSI Logic)
>>>  marvell      Marvell Technology Group Ltd.
>>>  maxim        Maxim Integrated Products
>>> +mediatek     MediaTek Inc.
>>>  microchip    Microchip Technology Inc.
>>>  mosaixtech   Mosaix Technologies, Inc.
>>>  moxa Moxa
>>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>>> index 5db05f6a..04d46ec 100644
>>> --- a/arch/arm/Kconfig
>>> +++ b/arch/arm/Kconfig
>>> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>>>
>>>  source "arch/arm/mach-imx/Kconfig"
>>>
>>> +source "arch/arm/mach-mediatek/Kconfig"
>>> +
>>>  source "arch/arm/mach-mxs/Kconfig"
>>>
>>>  source "arch/arm/mach-netx/Kconfig"
>>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>>> index 41c1931..8ce9774 100644
>>> --- a/arch/arm/Makefile
>>> +++ b/arch/arm/Makefile
>>> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)                += msm
>>>  machine-$(CONFIG_ARCH_MV78XX0)               += mv78xx0
>>>  machine-$(CONFIG_ARCH_MVEBU)         += mvebu
>>>  machine-$(CONFIG_ARCH_MXC)           += imx
>>> +machine-$(CONFIG_ARCH_MEDIATEK)              += mediatek
>>>  machine-$(CONFIG_ARCH_MXS)           += mxs
>>>  machine-$(CONFIG_ARCH_NETX)          += netx
>>>  machine-$(CONFIG_ARCH_NOMADIK)               += nomadik
>>> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
>>> new file mode 100644
>>> index 0000000..6dbb74f
>>> --- /dev/null
>>> +++ b/arch/arm/boot/dts/mtk6589.dtsi
>>> @@ -0,0 +1,105 @@
>>> +/*
>>> + * Copyright (c) 2014 MundoReader S.L.
>>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License as published by
>>> + * the Free Software Foundation; either version 2 of the License, or
>>> + * (at your option) any later version.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + */
>>> +
>>> +#include <dt-bindings/interrupt-controller/irq.h>
>>> +#include <dt-bindings/interrupt-controller/arm-gic.h>
>>> +#include "skeleton.dtsi"
>>> +
>>> +/ {
>>> +     compatible = "mediatek,mt6589";
>>> +     interrupt-parent = <&gic>;
>>> +
>>> +     cpus {
>>> +             #address-cells = <1>;
>>> +             #size-cells = <0>;
>>> +
>>> +             cpu@0 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x0>;
>>> +             };
>>> +             cpu@1 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x1>;
>>> +             };
>>> +             cpu@2 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x2>;
>>> +             };
>>> +             cpu@3 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x3>;
>>> +             };
>>> +
>>> +     };
>>> +
>>> +     clocks {
>>> +             #address-cells = <1>;
>>> +             #size-cells = <1>;
>>> +             ranges;
>>> +
>>> +             system_clk: system_clk {
>>> +                     compatible = "fixed-clock";
>>> +                     clock-frequency = <13000000>;
>>> +                     #clock-cells = <0>;
>>> +                     clock-output-names = "system_clk";
>>> +             };
>>
>> Is it really a fixed clock without any parent, or do you
>> declare it as a fixed clock because you don't have any clock
>> common framework support yet?
> 
> I don't have any common clock framework support yet.

So maybe you should provide one (even a very simple one).

Pretending a clock is a fixed clock and ignoring its parents
will be problematic when you will add the common clock framework
support because the device tree is supposed to be stable and you won't
be able to change it then.

Thanks,

Gregory

> 
>>
>>> +
>>> +             rtc_clk: rtc_clk {
>>> +                     compatible = "fixed-clock";
>>> +                     clock-frequency = <32000>;
>>> +                     #clock-cells = <0>;
>>> +                     clock-output-names = "rtc_clk";
>>> +             };
>>> +     };
>>> +
>>> +     soc {
>>> +             #address-cells = <1>;
>>> +             #size-cells = <1>;
>>> +             compatible = "simple-bus";
>>> +             clock-ranges;
>>> +             ranges;
>>> +
>>> +             gic: interrupt-controller@10212000 {
>>> +                     compatible = "arm,cortex-a9-gic";
>>> +                     interrupt-controller;
>>> +                     #interrupt-cells = <3>;
>>> +                     reg = <0x10211000 0x1000>,
>>> +                           <0x10212000 0x1000>;
>>> +             };
>>> +
>>> +             L2: l2-cache-controller@1020e000 {
>>> +                     compatible = "arm,pl310-cache";
>>> +                     reg = <0x1020e000 0x1000>;
>>> +                     cache-unified;
>>> +                     cache-level = <2>;
>>> +             };
>>> +
>>> +             timer: timer@10008000 {
>>> +                     compatible = "mediatek,mtk6589-timer";
>>> +                     reg = <0x10008000 0x80>;
>>> +                     interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
>>> +                     clocks = <&system_clk>, <&rtc_clk>;
>>> +                     clock-names = "sys_clk", "rtc_clk";
>>> +             };
>>> +     };
>>> +};
>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>> new file mode 100644
>>> index 0000000..c0139ca
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>> @@ -0,0 +1,14 @@
>>> +config ARCH_MEDIATEK
>>> +     bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>> +     select ARCH_REQUIRE_GPIOLIB
>>> +     select ARM_GIC
>>> +     select CACHE_L2X0
>>> +     select HAVE_ARM_TWD if LOCAL_TIMERS
>>
>> LOCAL_TIMERS no longer exist
>>
>>> +     select HAVE_SMP
>>> +     select LOCAL_TIMERS if SMP
>> ditto
>>
>> so what about this instead:
>>
>>         select HAVE_ARM_TWD if SMP
>>
>>
>> The rest of this patch looks good.
>>
>> Thanks,
>>
>> Gregory
>>
>>> +     select COMMON_CLK
>>> +     select GENERIC_CLOCKEVENTS
>>> +     select MTK_TIMER
>>> +     select CLKSRC_MMIO
>>> +     help
>>> +       Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
>>> diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
>>> new file mode 100644
>>> index 0000000..43e619f
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/Makefile
>>> @@ -0,0 +1 @@
>>> +obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
>>> diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
>>> new file mode 100644
>>> index 0000000..f630403
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/mediatek.c
>>> @@ -0,0 +1,40 @@
>>> +/*
>>> + * Device Tree support for Mediatek SoCs
>>> + *
>>> + * Copyright (c) 2014 MundoReader S.L.
>>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License as published by
>>> + * the Free Software Foundation; either version 2 of the License, or
>>> + * (at your option) any later version.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + */
>>> +
>>> +#include <linux/kernel.h>
>>> +#include <linux/init.h>
>>> +#include <linux/of_platform.h>
>>> +#include <linux/irqchip.h>
>>> +#include <asm/mach/arch.h>
>>> +#include <asm/mach/map.h>
>>> +#include <asm/hardware/cache-l2x0.h>
>>> +
>>> +static void __init mediatek_dt_init(void)
>>> +{
>>> +     l2x0_of_init(0, ~0);
>>> +     of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>>> +}
>>> +
>>> +static const char * const mediatek_board_dt_compat[] = {
>>> +     "mediatek,mt6589",
>>> +     NULL,
>>> +};
>>> +
>>> +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
>>> +     .init_machine   = mediatek_dt_init,
>>> +     .dt_compat      = mediatek_board_dt_compat,
>>> +MACHINE_END
>>>
>>
>>
>> --
>> Gregory Clement, Free Electrons
>> Kernel, drivers, real-time and embedded Linux
>> development, consulting, training and support.
>> http://free-electrons.com
> 
> 
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  8:46         ` Gregory CLEMENT
  0 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-10  8:46 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: linux-kernel, Mark Rutland, Andrew Lunn, linux-doc,
	Thierry Reding, Heiko Stübner, Russell King, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, Silvio F

On 10/04/2014 08:29, Matthias Brugger wrote:
> 2014-04-09 22:26 GMT+02:00 Gregory CLEMENT <gregory.clement@free-electrons.com>:
>> Hi Matthias,
>>
>> On 09/04/2014 19:45, Matthias Brugger wrote:
>>> This adds a generic devicetree board file and a dtsi for boards
>>> based on the MT6589 SoCs from Mediatek.
>>>
>>> Apart from the generic parts (gic, clocks) the only component
>>> currently supported are the timers.
>>>
>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>> ---
>>>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>>>  arch/arm/Kconfig                                   |    2 +
>>>  arch/arm/Makefile                                  |    1 +
>>>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++
>>>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>>>  arch/arm/mach-mediatek/Makefile                    |    1 +
>>>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>>>  7 files changed, 164 insertions(+)
>>>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>>>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>>>  create mode 100644 arch/arm/mach-mediatek/Makefile
>>>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
>>>
>>> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
>>> index 0f01c9b..af48801 100644
>>> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
>>> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
>>> @@ -67,6 +67,7 @@ linux       Linux-specific binding
>>>  lsi  LSI Corp. (LSI Logic)
>>>  marvell      Marvell Technology Group Ltd.
>>>  maxim        Maxim Integrated Products
>>> +mediatek     MediaTek Inc.
>>>  microchip    Microchip Technology Inc.
>>>  mosaixtech   Mosaix Technologies, Inc.
>>>  moxa Moxa
>>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>>> index 5db05f6a..04d46ec 100644
>>> --- a/arch/arm/Kconfig
>>> +++ b/arch/arm/Kconfig
>>> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>>>
>>>  source "arch/arm/mach-imx/Kconfig"
>>>
>>> +source "arch/arm/mach-mediatek/Kconfig"
>>> +
>>>  source "arch/arm/mach-mxs/Kconfig"
>>>
>>>  source "arch/arm/mach-netx/Kconfig"
>>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>>> index 41c1931..8ce9774 100644
>>> --- a/arch/arm/Makefile
>>> +++ b/arch/arm/Makefile
>>> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)                += msm
>>>  machine-$(CONFIG_ARCH_MV78XX0)               += mv78xx0
>>>  machine-$(CONFIG_ARCH_MVEBU)         += mvebu
>>>  machine-$(CONFIG_ARCH_MXC)           += imx
>>> +machine-$(CONFIG_ARCH_MEDIATEK)              += mediatek
>>>  machine-$(CONFIG_ARCH_MXS)           += mxs
>>>  machine-$(CONFIG_ARCH_NETX)          += netx
>>>  machine-$(CONFIG_ARCH_NOMADIK)               += nomadik
>>> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
>>> new file mode 100644
>>> index 0000000..6dbb74f
>>> --- /dev/null
>>> +++ b/arch/arm/boot/dts/mtk6589.dtsi
>>> @@ -0,0 +1,105 @@
>>> +/*
>>> + * Copyright (c) 2014 MundoReader S.L.
>>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License as published by
>>> + * the Free Software Foundation; either version 2 of the License, or
>>> + * (at your option) any later version.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + */
>>> +
>>> +#include <dt-bindings/interrupt-controller/irq.h>
>>> +#include <dt-bindings/interrupt-controller/arm-gic.h>
>>> +#include "skeleton.dtsi"
>>> +
>>> +/ {
>>> +     compatible = "mediatek,mt6589";
>>> +     interrupt-parent = <&gic>;
>>> +
>>> +     cpus {
>>> +             #address-cells = <1>;
>>> +             #size-cells = <0>;
>>> +
>>> +             cpu@0 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x0>;
>>> +             };
>>> +             cpu@1 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x1>;
>>> +             };
>>> +             cpu@2 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x2>;
>>> +             };
>>> +             cpu@3 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x3>;
>>> +             };
>>> +
>>> +     };
>>> +
>>> +     clocks {
>>> +             #address-cells = <1>;
>>> +             #size-cells = <1>;
>>> +             ranges;
>>> +
>>> +             system_clk: system_clk {
>>> +                     compatible = "fixed-clock";
>>> +                     clock-frequency = <13000000>;
>>> +                     #clock-cells = <0>;
>>> +                     clock-output-names = "system_clk";
>>> +             };
>>
>> Is it really a fixed clock without any parent, or do you
>> declare it as a fixed clock because you don't have any clock
>> common framework support yet?
> 
> I don't have any common clock framework support yet.

So maybe you should provide one (even a very simple one).

Pretending a clock is a fixed clock and ignoring its parents
will be problematic when you will add the common clock framework
support because the device tree is supposed to be stable and you won't
be able to change it then.

Thanks,

Gregory

> 
>>
>>> +
>>> +             rtc_clk: rtc_clk {
>>> +                     compatible = "fixed-clock";
>>> +                     clock-frequency = <32000>;
>>> +                     #clock-cells = <0>;
>>> +                     clock-output-names = "rtc_clk";
>>> +             };
>>> +     };
>>> +
>>> +     soc {
>>> +             #address-cells = <1>;
>>> +             #size-cells = <1>;
>>> +             compatible = "simple-bus";
>>> +             clock-ranges;
>>> +             ranges;
>>> +
>>> +             gic: interrupt-controller@10212000 {
>>> +                     compatible = "arm,cortex-a9-gic";
>>> +                     interrupt-controller;
>>> +                     #interrupt-cells = <3>;
>>> +                     reg = <0x10211000 0x1000>,
>>> +                           <0x10212000 0x1000>;
>>> +             };
>>> +
>>> +             L2: l2-cache-controller@1020e000 {
>>> +                     compatible = "arm,pl310-cache";
>>> +                     reg = <0x1020e000 0x1000>;
>>> +                     cache-unified;
>>> +                     cache-level = <2>;
>>> +             };
>>> +
>>> +             timer: timer@10008000 {
>>> +                     compatible = "mediatek,mtk6589-timer";
>>> +                     reg = <0x10008000 0x80>;
>>> +                     interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
>>> +                     clocks = <&system_clk>, <&rtc_clk>;
>>> +                     clock-names = "sys_clk", "rtc_clk";
>>> +             };
>>> +     };
>>> +};
>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>> new file mode 100644
>>> index 0000000..c0139ca
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>> @@ -0,0 +1,14 @@
>>> +config ARCH_MEDIATEK
>>> +     bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>> +     select ARCH_REQUIRE_GPIOLIB
>>> +     select ARM_GIC
>>> +     select CACHE_L2X0
>>> +     select HAVE_ARM_TWD if LOCAL_TIMERS
>>
>> LOCAL_TIMERS no longer exist
>>
>>> +     select HAVE_SMP
>>> +     select LOCAL_TIMERS if SMP
>> ditto
>>
>> so what about this instead:
>>
>>         select HAVE_ARM_TWD if SMP
>>
>>
>> The rest of this patch looks good.
>>
>> Thanks,
>>
>> Gregory
>>
>>> +     select COMMON_CLK
>>> +     select GENERIC_CLOCKEVENTS
>>> +     select MTK_TIMER
>>> +     select CLKSRC_MMIO
>>> +     help
>>> +       Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
>>> diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
>>> new file mode 100644
>>> index 0000000..43e619f
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/Makefile
>>> @@ -0,0 +1 @@
>>> +obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
>>> diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
>>> new file mode 100644
>>> index 0000000..f630403
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/mediatek.c
>>> @@ -0,0 +1,40 @@
>>> +/*
>>> + * Device Tree support for Mediatek SoCs
>>> + *
>>> + * Copyright (c) 2014 MundoReader S.L.
>>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License as published by
>>> + * the Free Software Foundation; either version 2 of the License, or
>>> + * (at your option) any later version.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + */
>>> +
>>> +#include <linux/kernel.h>
>>> +#include <linux/init.h>
>>> +#include <linux/of_platform.h>
>>> +#include <linux/irqchip.h>
>>> +#include <asm/mach/arch.h>
>>> +#include <asm/mach/map.h>
>>> +#include <asm/hardware/cache-l2x0.h>
>>> +
>>> +static void __init mediatek_dt_init(void)
>>> +{
>>> +     l2x0_of_init(0, ~0);
>>> +     of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>>> +}
>>> +
>>> +static const char * const mediatek_board_dt_compat[] = {
>>> +     "mediatek,mt6589",
>>> +     NULL,
>>> +};
>>> +
>>> +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
>>> +     .init_machine   = mediatek_dt_init,
>>> +     .dt_compat      = mediatek_board_dt_compat,
>>> +MACHINE_END
>>>
>>
>>
>> --
>> Gregory Clement, Free Electrons
>> Kernel, drivers, real-time and embedded Linux
>> development, consulting, training and support.
>> http://free-electrons.com
> 
> 
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  8:46         ` Gregory CLEMENT
  0 siblings, 0 replies; 74+ messages in thread
From: Gregory CLEMENT @ 2014-04-10  8:46 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/04/2014 08:29, Matthias Brugger wrote:
> 2014-04-09 22:26 GMT+02:00 Gregory CLEMENT <gregory.clement@free-electrons.com>:
>> Hi Matthias,
>>
>> On 09/04/2014 19:45, Matthias Brugger wrote:
>>> This adds a generic devicetree board file and a dtsi for boards
>>> based on the MT6589 SoCs from Mediatek.
>>>
>>> Apart from the generic parts (gic, clocks) the only component
>>> currently supported are the timers.
>>>
>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>> ---
>>>  .../devicetree/bindings/vendor-prefixes.txt        |    1 +
>>>  arch/arm/Kconfig                                   |    2 +
>>>  arch/arm/Makefile                                  |    1 +
>>>  arch/arm/boot/dts/mtk6589.dtsi                     |  105 ++++++++++++++++++++
>>>  arch/arm/mach-mediatek/Kconfig                     |   14 +++
>>>  arch/arm/mach-mediatek/Makefile                    |    1 +
>>>  arch/arm/mach-mediatek/mediatek.c                  |   40 ++++++++
>>>  7 files changed, 164 insertions(+)
>>>  create mode 100644 arch/arm/boot/dts/mtk6589.dtsi
>>>  create mode 100644 arch/arm/mach-mediatek/Kconfig
>>>  create mode 100644 arch/arm/mach-mediatek/Makefile
>>>  create mode 100644 arch/arm/mach-mediatek/mediatek.c
>>>
>>> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
>>> index 0f01c9b..af48801 100644
>>> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
>>> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
>>> @@ -67,6 +67,7 @@ linux       Linux-specific binding
>>>  lsi  LSI Corp. (LSI Logic)
>>>  marvell      Marvell Technology Group Ltd.
>>>  maxim        Maxim Integrated Products
>>> +mediatek     MediaTek Inc.
>>>  microchip    Microchip Technology Inc.
>>>  mosaixtech   Mosaix Technologies, Inc.
>>>  moxa Moxa
>>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>>> index 5db05f6a..04d46ec 100644
>>> --- a/arch/arm/Kconfig
>>> +++ b/arch/arm/Kconfig
>>> @@ -995,6 +995,8 @@ source "arch/arm/mach-mv78xx0/Kconfig"
>>>
>>>  source "arch/arm/mach-imx/Kconfig"
>>>
>>> +source "arch/arm/mach-mediatek/Kconfig"
>>> +
>>>  source "arch/arm/mach-mxs/Kconfig"
>>>
>>>  source "arch/arm/mach-netx/Kconfig"
>>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>>> index 41c1931..8ce9774 100644
>>> --- a/arch/arm/Makefile
>>> +++ b/arch/arm/Makefile
>>> @@ -170,6 +170,7 @@ machine-$(CONFIG_ARCH_MSM)                += msm
>>>  machine-$(CONFIG_ARCH_MV78XX0)               += mv78xx0
>>>  machine-$(CONFIG_ARCH_MVEBU)         += mvebu
>>>  machine-$(CONFIG_ARCH_MXC)           += imx
>>> +machine-$(CONFIG_ARCH_MEDIATEK)              += mediatek
>>>  machine-$(CONFIG_ARCH_MXS)           += mxs
>>>  machine-$(CONFIG_ARCH_NETX)          += netx
>>>  machine-$(CONFIG_ARCH_NOMADIK)               += nomadik
>>> diff --git a/arch/arm/boot/dts/mtk6589.dtsi b/arch/arm/boot/dts/mtk6589.dtsi
>>> new file mode 100644
>>> index 0000000..6dbb74f
>>> --- /dev/null
>>> +++ b/arch/arm/boot/dts/mtk6589.dtsi
>>> @@ -0,0 +1,105 @@
>>> +/*
>>> + * Copyright (c) 2014 MundoReader S.L.
>>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License as published by
>>> + * the Free Software Foundation; either version 2 of the License, or
>>> + * (at your option) any later version.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + */
>>> +
>>> +#include <dt-bindings/interrupt-controller/irq.h>
>>> +#include <dt-bindings/interrupt-controller/arm-gic.h>
>>> +#include "skeleton.dtsi"
>>> +
>>> +/ {
>>> +     compatible = "mediatek,mt6589";
>>> +     interrupt-parent = <&gic>;
>>> +
>>> +     cpus {
>>> +             #address-cells = <1>;
>>> +             #size-cells = <0>;
>>> +
>>> +             cpu at 0 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x0>;
>>> +             };
>>> +             cpu at 1 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x1>;
>>> +             };
>>> +             cpu at 2 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x2>;
>>> +             };
>>> +             cpu at 3 {
>>> +                     device_type = "cpu";
>>> +                     compatible = "arm,cortex-a7";
>>> +                     next-level-cache = <&L2>;
>>> +                     reg = <0x3>;
>>> +             };
>>> +
>>> +     };
>>> +
>>> +     clocks {
>>> +             #address-cells = <1>;
>>> +             #size-cells = <1>;
>>> +             ranges;
>>> +
>>> +             system_clk: system_clk {
>>> +                     compatible = "fixed-clock";
>>> +                     clock-frequency = <13000000>;
>>> +                     #clock-cells = <0>;
>>> +                     clock-output-names = "system_clk";
>>> +             };
>>
>> Is it really a fixed clock without any parent, or do you
>> declare it as a fixed clock because you don't have any clock
>> common framework support yet?
> 
> I don't have any common clock framework support yet.

So maybe you should provide one (even a very simple one).

Pretending a clock is a fixed clock and ignoring its parents
will be problematic when you will add the common clock framework
support because the device tree is supposed to be stable and you won't
be able to change it then.

Thanks,

Gregory

> 
>>
>>> +
>>> +             rtc_clk: rtc_clk {
>>> +                     compatible = "fixed-clock";
>>> +                     clock-frequency = <32000>;
>>> +                     #clock-cells = <0>;
>>> +                     clock-output-names = "rtc_clk";
>>> +             };
>>> +     };
>>> +
>>> +     soc {
>>> +             #address-cells = <1>;
>>> +             #size-cells = <1>;
>>> +             compatible = "simple-bus";
>>> +             clock-ranges;
>>> +             ranges;
>>> +
>>> +             gic: interrupt-controller at 10212000 {
>>> +                     compatible = "arm,cortex-a9-gic";
>>> +                     interrupt-controller;
>>> +                     #interrupt-cells = <3>;
>>> +                     reg = <0x10211000 0x1000>,
>>> +                           <0x10212000 0x1000>;
>>> +             };
>>> +
>>> +             L2: l2-cache-controller at 1020e000 {
>>> +                     compatible = "arm,pl310-cache";
>>> +                     reg = <0x1020e000 0x1000>;
>>> +                     cache-unified;
>>> +                     cache-level = <2>;
>>> +             };
>>> +
>>> +             timer: timer at 10008000 {
>>> +                     compatible = "mediatek,mtk6589-timer";
>>> +                     reg = <0x10008000 0x80>;
>>> +                     interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
>>> +                     clocks = <&system_clk>, <&rtc_clk>;
>>> +                     clock-names = "sys_clk", "rtc_clk";
>>> +             };
>>> +     };
>>> +};
>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>> new file mode 100644
>>> index 0000000..c0139ca
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>> @@ -0,0 +1,14 @@
>>> +config ARCH_MEDIATEK
>>> +     bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>> +     select ARCH_REQUIRE_GPIOLIB
>>> +     select ARM_GIC
>>> +     select CACHE_L2X0
>>> +     select HAVE_ARM_TWD if LOCAL_TIMERS
>>
>> LOCAL_TIMERS no longer exist
>>
>>> +     select HAVE_SMP
>>> +     select LOCAL_TIMERS if SMP
>> ditto
>>
>> so what about this instead:
>>
>>         select HAVE_ARM_TWD if SMP
>>
>>
>> The rest of this patch looks good.
>>
>> Thanks,
>>
>> Gregory
>>
>>> +     select COMMON_CLK
>>> +     select GENERIC_CLOCKEVENTS
>>> +     select MTK_TIMER
>>> +     select CLKSRC_MMIO
>>> +     help
>>> +       Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
>>> diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
>>> new file mode 100644
>>> index 0000000..43e619f
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/Makefile
>>> @@ -0,0 +1 @@
>>> +obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
>>> diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
>>> new file mode 100644
>>> index 0000000..f630403
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/mediatek.c
>>> @@ -0,0 +1,40 @@
>>> +/*
>>> + * Device Tree support for Mediatek SoCs
>>> + *
>>> + * Copyright (c) 2014 MundoReader S.L.
>>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License as published by
>>> + * the Free Software Foundation; either version 2 of the License, or
>>> + * (at your option) any later version.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + */
>>> +
>>> +#include <linux/kernel.h>
>>> +#include <linux/init.h>
>>> +#include <linux/of_platform.h>
>>> +#include <linux/irqchip.h>
>>> +#include <asm/mach/arch.h>
>>> +#include <asm/mach/map.h>
>>> +#include <asm/hardware/cache-l2x0.h>
>>> +
>>> +static void __init mediatek_dt_init(void)
>>> +{
>>> +     l2x0_of_init(0, ~0);
>>> +     of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>>> +}
>>> +
>>> +static const char * const mediatek_board_dt_compat[] = {
>>> +     "mediatek,mt6589",
>>> +     NULL,
>>> +};
>>> +
>>> +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
>>> +     .init_machine   = mediatek_dt_init,
>>> +     .dt_compat      = mediatek_board_dt_compat,
>>> +MACHINE_END
>>>
>>
>>
>> --
>> Gregory Clement, Free Electrons
>> Kernel, drivers, real-time and embedded Linux
>> development, consulting, training and support.
>> http://free-electrons.com
> 
> 
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-09 21:50     ` Rob Herring
  (?)
@ 2014-04-10  9:01       ` Marc Zyngier
  -1 siblings, 0 replies; 74+ messages in thread
From: Marc Zyngier @ 2014-04-10  9:01 UTC (permalink / raw)
  To: Rob Herring, Matthias Brugger
  Cc: Mark Rutland, Andrew Lunn, linux-doc, Thierry Reding,
	heiko.stuebner, Russell King - ARM Linux, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, linux-kernel,
	Silvio F, Kumar Gala, Olof Johansson, Jonathan Cameron

A couple of things on top of Rob's comments:

On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>> This adds a generic devicetree board file and a dtsi for boards
>> based on the MT6589 SoCs from Mediatek.
>>
>> Apart from the generic parts (gic, clocks) the only component
>> currently supported are the timers.
>>
>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>

[...]

>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>> new file mode 100644
>> index 0000000..c0139ca
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/Kconfig
>> @@ -0,0 +1,14 @@
>> +config ARCH_MEDIATEK
>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>> +       select ARCH_REQUIRE_GPIOLIB
>
> Then where is your GPIO driver?
>
>> +       select ARM_GIC
>> +       select CACHE_L2X0
>> +       select HAVE_ARM_TWD if LOCAL_TIMERS

Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
node).

>> +       select HAVE_SMP
>
> Not needed now (going into 3.15).
>
>> +       select LOCAL_TIMERS if SMP

No, A7 always have the arch timers.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny.

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  9:01       ` Marc Zyngier
  0 siblings, 0 replies; 74+ messages in thread
From: Marc Zyngier @ 2014-04-10  9:01 UTC (permalink / raw)
  To: Rob Herring, Matthias Brugger
  Cc: Mark Rutland, Andrew Lunn, linux-doc, Thierry Reding,
	heiko.stuebner, Russell King - ARM Linux, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, linux-kernel,
	Silvio F

A couple of things on top of Rob's comments:

On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>> This adds a generic devicetree board file and a dtsi for boards
>> based on the MT6589 SoCs from Mediatek.
>>
>> Apart from the generic parts (gic, clocks) the only component
>> currently supported are the timers.
>>
>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>

[...]

>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>> new file mode 100644
>> index 0000000..c0139ca
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/Kconfig
>> @@ -0,0 +1,14 @@
>> +config ARCH_MEDIATEK
>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>> +       select ARCH_REQUIRE_GPIOLIB
>
> Then where is your GPIO driver?
>
>> +       select ARM_GIC
>> +       select CACHE_L2X0
>> +       select HAVE_ARM_TWD if LOCAL_TIMERS

Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
node).

>> +       select HAVE_SMP
>
> Not needed now (going into 3.15).
>
>> +       select LOCAL_TIMERS if SMP

No, A7 always have the arch timers.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny.

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  9:01       ` Marc Zyngier
  0 siblings, 0 replies; 74+ messages in thread
From: Marc Zyngier @ 2014-04-10  9:01 UTC (permalink / raw)
  To: linux-arm-kernel

A couple of things on top of Rob's comments:

On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>> This adds a generic devicetree board file and a dtsi for boards
>> based on the MT6589 SoCs from Mediatek.
>>
>> Apart from the generic parts (gic, clocks) the only component
>> currently supported are the timers.
>>
>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>

[...]

>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>> new file mode 100644
>> index 0000000..c0139ca
>> --- /dev/null
>> +++ b/arch/arm/mach-mediatek/Kconfig
>> @@ -0,0 +1,14 @@
>> +config ARCH_MEDIATEK
>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>> +       select ARCH_REQUIRE_GPIOLIB
>
> Then where is your GPIO driver?
>
>> +       select ARM_GIC
>> +       select CACHE_L2X0
>> +       select HAVE_ARM_TWD if LOCAL_TIMERS

Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
node).

>> +       select HAVE_SMP
>
> Not needed now (going into 3.15).
>
>> +       select LOCAL_TIMERS if SMP

No, A7 always have the arch timers.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny.

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-10  7:36     ` Arnd Bergmann
@ 2014-04-10  9:15       ` Matthias Brugger
  -1 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-10  9:15 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mark Rutland, Andrew Lunn, linux-doc, Thierry Reding,
	Heiko Stübner, Russell King, Daniel Lezcano, rmk+kernel,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, linux-kernel

2014-04-10 9:36 GMT+02:00 Arnd Bergmann <arnd@arndb.de>:
> On Wednesday 09 April 2014 21:45:35 Matthias Brugger wrote:
>> This adds a generic devicetree board file and a dtsi for boards
>> based on the MT6589 SoCs from Mediatek.
>>
>> Apart from the generic parts (gic, clocks) the only component
>> currently supported are the timers.
>>
>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>
> Hi Matthias,
>
> First of all, I'm really glad to see this get started, thanks for looking
> into these!
>
> Do you know how similar the MT6589 is to the later chips like MT65x2
> and MT6588? What are the on-chip devices like, is it mostly licensed
> IP blocks from designware and others that we already have drivers for,
> or all new drivers?

Actually I don't have any information about the MT6589.
For MT6572 I had a deeper look on the GPT and the UART which seem to
be the same in both SoCs.
But they don't look like IP blocks from any other vendor. Most of the
other on-chip devices look quite similar.
In any case don't trust me too much, as I'm just doing my first steps
on an effort like this.

>
>> +#include <asm/hardware/cache-l2x0.h>
>> +
>> +static void __init mediatek_dt_init(void)
>> +{
>> +     l2x0_of_init(0, ~0);
>> +     of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>> +}
>
> I hope that with all the cleanup work that Russell has done in the
> past few weeks, we can manage to kill off the call to l2x0_of_init()
> here and have it done by core architecture code instead. That would
> let you have an empty machine file, unless you have other things you
> will need to add in the future.
>
>         Arnd



-- 
motzblog.wordpress.com

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  9:15       ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-10  9:15 UTC (permalink / raw)
  To: linux-arm-kernel

2014-04-10 9:36 GMT+02:00 Arnd Bergmann <arnd@arndb.de>:
> On Wednesday 09 April 2014 21:45:35 Matthias Brugger wrote:
>> This adds a generic devicetree board file and a dtsi for boards
>> based on the MT6589 SoCs from Mediatek.
>>
>> Apart from the generic parts (gic, clocks) the only component
>> currently supported are the timers.
>>
>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>
> Hi Matthias,
>
> First of all, I'm really glad to see this get started, thanks for looking
> into these!
>
> Do you know how similar the MT6589 is to the later chips like MT65x2
> and MT6588? What are the on-chip devices like, is it mostly licensed
> IP blocks from designware and others that we already have drivers for,
> or all new drivers?

Actually I don't have any information about the MT6589.
For MT6572 I had a deeper look on the GPT and the UART which seem to
be the same in both SoCs.
But they don't look like IP blocks from any other vendor. Most of the
other on-chip devices look quite similar.
In any case don't trust me too much, as I'm just doing my first steps
on an effort like this.

>
>> +#include <asm/hardware/cache-l2x0.h>
>> +
>> +static void __init mediatek_dt_init(void)
>> +{
>> +     l2x0_of_init(0, ~0);
>> +     of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>> +}
>
> I hope that with all the cleanup work that Russell has done in the
> past few weeks, we can manage to kill off the call to l2x0_of_init()
> here and have it done by core architecture code instead. That would
> let you have an empty machine file, unless you have other things you
> will need to add in the future.
>
>         Arnd



-- 
motzblog.wordpress.com

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-10  8:46         ` Gregory CLEMENT
  (?)
@ 2014-04-10  9:34           ` Heiko Stübner
  -1 siblings, 0 replies; 74+ messages in thread
From: Heiko Stübner @ 2014-04-10  9:34 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: Matthias Brugger, linux-kernel, Mark Rutland, Andrew Lunn,
	linux-doc, Thierry Reding, Russell King, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, Silvio F,
	Kumar Gala, Olof Johansson, Jonathan Cameron

Hi Gregory,

Am Donnerstag, 10. April 2014, 08:46:03 schrieb Gregory CLEMENT:
> On 10/04/2014 08:29, Matthias Brugger wrote:
> > 2014-04-09 22:26 GMT+02:00 Gregory CLEMENT <gregory.clement@free-
electrons.com>:
> >> Hi Matthias,
> >> 
> >> On 09/04/2014 19:45, Matthias Brugger wrote:
> >>> diff --git a/arch/arm/boot/dts/mtk6589.dtsi
> >>> b/arch/arm/boot/dts/mtk6589.dtsi new file mode 100644
> >>> index 0000000..6dbb74f
> >>> --- /dev/null
> >>> +++ b/arch/arm/boot/dts/mtk6589.dtsi
> >>> @@ -0,0 +1,105 @@
> >>> +/*
> >>> + * Copyright (c) 2014 MundoReader S.L.
> >>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> >>> + *
> >>> + * This program is free software; you can redistribute it and/or modify
> >>> + * it under the terms of the GNU General Public License as published by
> >>> + * the Free Software Foundation; either version 2 of the License, or
> >>> + * (at your option) any later version.
> >>> + *
> >>> + * This program is distributed in the hope that it will be useful,
> >>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >>> + * GNU General Public License for more details.
> >>> + */
> >>> +
> >>> +#include <dt-bindings/interrupt-controller/irq.h>
> >>> +#include <dt-bindings/interrupt-controller/arm-gic.h>
> >>> +#include "skeleton.dtsi"
> >>> +
> >>> +/ {
> >>> +     compatible = "mediatek,mt6589";
> >>> +     interrupt-parent = <&gic>;
> >>> +
> >>> +     cpus {
> >>> +             #address-cells = <1>;
> >>> +             #size-cells = <0>;
> >>> +
> >>> +             cpu@0 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x0>;
> >>> +             };
> >>> +             cpu@1 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x1>;
> >>> +             };
> >>> +             cpu@2 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x2>;
> >>> +             };
> >>> +             cpu@3 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x3>;
> >>> +             };
> >>> +
> >>> +     };
> >>> +
> >>> +     clocks {
> >>> +             #address-cells = <1>;
> >>> +             #size-cells = <1>;
> >>> +             ranges;
> >>> +
> >>> +             system_clk: system_clk {
> >>> +                     compatible = "fixed-clock";
> >>> +                     clock-frequency = <13000000>;
> >>> +                     #clock-cells = <0>;
> >>> +                     clock-output-names = "system_clk";
> >>> +             };
> >> 
> >> Is it really a fixed clock without any parent, or do you
> >> declare it as a fixed clock because you don't have any clock
> >> common framework support yet?
> > 
> > I don't have any common clock framework support yet.
> 
> So maybe you should provide one (even a very simple one).
> 
> Pretending a clock is a fixed clock and ignoring its parents
> will be problematic when you will add the common clock framework
> support because the device tree is supposed to be stable and you won't
> be able to change it then.

personally I think the danger of introducing unsuitable bindings/precedents 
for a clock controller before it is fully understood is higher.

I'd just rename the clock above to something like dummy130m like sunxi also 
does for example, to reflect its unfinished state and when the clock controller 
is present later on change the supplying clock of the timer.

Or maybe I'm overlooking something here :-)


Heiko

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  9:34           ` Heiko Stübner
  0 siblings, 0 replies; 74+ messages in thread
From: Heiko Stübner @ 2014-04-10  9:34 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: Matthias Brugger, linux-kernel, Mark Rutland, Andrew Lunn,
	linux-doc, Thierry Reding, Russell King, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, Silvio F,
	Kumar Gala

Hi Gregory,

Am Donnerstag, 10. April 2014, 08:46:03 schrieb Gregory CLEMENT:
> On 10/04/2014 08:29, Matthias Brugger wrote:
> > 2014-04-09 22:26 GMT+02:00 Gregory CLEMENT <gregory.clement@free-
electrons.com>:
> >> Hi Matthias,
> >> 
> >> On 09/04/2014 19:45, Matthias Brugger wrote:
> >>> diff --git a/arch/arm/boot/dts/mtk6589.dtsi
> >>> b/arch/arm/boot/dts/mtk6589.dtsi new file mode 100644
> >>> index 0000000..6dbb74f
> >>> --- /dev/null
> >>> +++ b/arch/arm/boot/dts/mtk6589.dtsi
> >>> @@ -0,0 +1,105 @@
> >>> +/*
> >>> + * Copyright (c) 2014 MundoReader S.L.
> >>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> >>> + *
> >>> + * This program is free software; you can redistribute it and/or modify
> >>> + * it under the terms of the GNU General Public License as published by
> >>> + * the Free Software Foundation; either version 2 of the License, or
> >>> + * (at your option) any later version.
> >>> + *
> >>> + * This program is distributed in the hope that it will be useful,
> >>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >>> + * GNU General Public License for more details.
> >>> + */
> >>> +
> >>> +#include <dt-bindings/interrupt-controller/irq.h>
> >>> +#include <dt-bindings/interrupt-controller/arm-gic.h>
> >>> +#include "skeleton.dtsi"
> >>> +
> >>> +/ {
> >>> +     compatible = "mediatek,mt6589";
> >>> +     interrupt-parent = <&gic>;
> >>> +
> >>> +     cpus {
> >>> +             #address-cells = <1>;
> >>> +             #size-cells = <0>;
> >>> +
> >>> +             cpu@0 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x0>;
> >>> +             };
> >>> +             cpu@1 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x1>;
> >>> +             };
> >>> +             cpu@2 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x2>;
> >>> +             };
> >>> +             cpu@3 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x3>;
> >>> +             };
> >>> +
> >>> +     };
> >>> +
> >>> +     clocks {
> >>> +             #address-cells = <1>;
> >>> +             #size-cells = <1>;
> >>> +             ranges;
> >>> +
> >>> +             system_clk: system_clk {
> >>> +                     compatible = "fixed-clock";
> >>> +                     clock-frequency = <13000000>;
> >>> +                     #clock-cells = <0>;
> >>> +                     clock-output-names = "system_clk";
> >>> +             };
> >> 
> >> Is it really a fixed clock without any parent, or do you
> >> declare it as a fixed clock because you don't have any clock
> >> common framework support yet?
> > 
> > I don't have any common clock framework support yet.
> 
> So maybe you should provide one (even a very simple one).
> 
> Pretending a clock is a fixed clock and ignoring its parents
> will be problematic when you will add the common clock framework
> support because the device tree is supposed to be stable and you won't
> be able to change it then.

personally I think the danger of introducing unsuitable bindings/precedents 
for a clock controller before it is fully understood is higher.

I'd just rename the clock above to something like dummy130m like sunxi also 
does for example, to reflect its unfinished state and when the clock controller 
is present later on change the supplying clock of the timer.

Or maybe I'm overlooking something here :-)


Heiko

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  9:34           ` Heiko Stübner
  0 siblings, 0 replies; 74+ messages in thread
From: Heiko Stübner @ 2014-04-10  9:34 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Gregory,

Am Donnerstag, 10. April 2014, 08:46:03 schrieb Gregory CLEMENT:
> On 10/04/2014 08:29, Matthias Brugger wrote:
> > 2014-04-09 22:26 GMT+02:00 Gregory CLEMENT <gregory.clement@free-
electrons.com>:
> >> Hi Matthias,
> >> 
> >> On 09/04/2014 19:45, Matthias Brugger wrote:
> >>> diff --git a/arch/arm/boot/dts/mtk6589.dtsi
> >>> b/arch/arm/boot/dts/mtk6589.dtsi new file mode 100644
> >>> index 0000000..6dbb74f
> >>> --- /dev/null
> >>> +++ b/arch/arm/boot/dts/mtk6589.dtsi
> >>> @@ -0,0 +1,105 @@
> >>> +/*
> >>> + * Copyright (c) 2014 MundoReader S.L.
> >>> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> >>> + *
> >>> + * This program is free software; you can redistribute it and/or modify
> >>> + * it under the terms of the GNU General Public License as published by
> >>> + * the Free Software Foundation; either version 2 of the License, or
> >>> + * (at your option) any later version.
> >>> + *
> >>> + * This program is distributed in the hope that it will be useful,
> >>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >>> + * GNU General Public License for more details.
> >>> + */
> >>> +
> >>> +#include <dt-bindings/interrupt-controller/irq.h>
> >>> +#include <dt-bindings/interrupt-controller/arm-gic.h>
> >>> +#include "skeleton.dtsi"
> >>> +
> >>> +/ {
> >>> +     compatible = "mediatek,mt6589";
> >>> +     interrupt-parent = <&gic>;
> >>> +
> >>> +     cpus {
> >>> +             #address-cells = <1>;
> >>> +             #size-cells = <0>;
> >>> +
> >>> +             cpu at 0 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x0>;
> >>> +             };
> >>> +             cpu at 1 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x1>;
> >>> +             };
> >>> +             cpu at 2 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x2>;
> >>> +             };
> >>> +             cpu at 3 {
> >>> +                     device_type = "cpu";
> >>> +                     compatible = "arm,cortex-a7";
> >>> +                     next-level-cache = <&L2>;
> >>> +                     reg = <0x3>;
> >>> +             };
> >>> +
> >>> +     };
> >>> +
> >>> +     clocks {
> >>> +             #address-cells = <1>;
> >>> +             #size-cells = <1>;
> >>> +             ranges;
> >>> +
> >>> +             system_clk: system_clk {
> >>> +                     compatible = "fixed-clock";
> >>> +                     clock-frequency = <13000000>;
> >>> +                     #clock-cells = <0>;
> >>> +                     clock-output-names = "system_clk";
> >>> +             };
> >> 
> >> Is it really a fixed clock without any parent, or do you
> >> declare it as a fixed clock because you don't have any clock
> >> common framework support yet?
> > 
> > I don't have any common clock framework support yet.
> 
> So maybe you should provide one (even a very simple one).
> 
> Pretending a clock is a fixed clock and ignoring its parents
> will be problematic when you will add the common clock framework
> support because the device tree is supposed to be stable and you won't
> be able to change it then.

personally I think the danger of introducing unsuitable bindings/precedents 
for a clock controller before it is fully understood is higher.

I'd just rename the clock above to something like dummy130m like sunxi also 
does for example, to reflect its unfinished state and when the clock controller 
is present later on change the supplying clock of the timer.

Or maybe I'm overlooking something here :-)


Heiko

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-10  8:46         ` Gregory CLEMENT
  (?)
@ 2014-04-10  9:36           ` Arnd Bergmann
  -1 siblings, 0 replies; 74+ messages in thread
From: Arnd Bergmann @ 2014-04-10  9:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Gregory CLEMENT, Matthias Brugger, Mark Rutland, Andrew Lunn,
	linux-doc, Thierry Reding, Heiko Stübner, Russell King,
	Daniel Lezcano, Florian Vaussard, Sebastian Hesselbarth,
	devicetree, Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, Randy Dunlap, linux-kernel, Silvio F,
	Kumar Gala, Olof Johansson, Jonathan Cameron

On Thursday 10 April 2014 08:46:03 Gregory CLEMENT wrote:
> >>
> >> Is it really a fixed clock without any parent, or do you
> >> declare it as a fixed clock because you don't have any clock
> >> common framework support yet?
> > 
> > I don't have any common clock framework support yet.
> 
> So maybe you should provide one (even a very simple one).
> 
> Pretending a clock is a fixed clock and ignoring its parents
> will be problematic when you will add the common clock framework
> support because the device tree is supposed to be stable and you won't
> be able to change it then.

But is this actually a problem here? The current device tree file
will keep working even if the proper driver is there, you just need
to update both the driver and the dts file in order to actually
use the clocks at run-time.

I guess it comes down to the question of whether we want to handle
old kernels with new device trees again, which would be broken here.

	Arnd

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  9:36           ` Arnd Bergmann
  0 siblings, 0 replies; 74+ messages in thread
From: Arnd Bergmann @ 2014-04-10  9:36 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Gregory CLEMENT, Matthias Brugger, Mark Rutland, Andrew Lunn,
	linux-doc, Thierry Reding, Heiko Stübner, Russell King,
	Daniel Lezcano, Florian Vaussard, Sebastian Hesselbarth,
	devicetree, Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, Randy Dunlap, linux-kernel

On Thursday 10 April 2014 08:46:03 Gregory CLEMENT wrote:
> >>
> >> Is it really a fixed clock without any parent, or do you
> >> declare it as a fixed clock because you don't have any clock
> >> common framework support yet?
> > 
> > I don't have any common clock framework support yet.
> 
> So maybe you should provide one (even a very simple one).
> 
> Pretending a clock is a fixed clock and ignoring its parents
> will be problematic when you will add the common clock framework
> support because the device tree is supposed to be stable and you won't
> be able to change it then.

But is this actually a problem here? The current device tree file
will keep working even if the proper driver is there, you just need
to update both the driver and the dts file in order to actually
use the clocks at run-time.

I guess it comes down to the question of whether we want to handle
old kernels with new device trees again, which would be broken here.

	Arnd

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-10  9:36           ` Arnd Bergmann
  0 siblings, 0 replies; 74+ messages in thread
From: Arnd Bergmann @ 2014-04-10  9:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Thursday 10 April 2014 08:46:03 Gregory CLEMENT wrote:
> >>
> >> Is it really a fixed clock without any parent, or do you
> >> declare it as a fixed clock because you don't have any clock
> >> common framework support yet?
> > 
> > I don't have any common clock framework support yet.
> 
> So maybe you should provide one (even a very simple one).
> 
> Pretending a clock is a fixed clock and ignoring its parents
> will be problematic when you will add the common clock framework
> support because the device tree is supposed to be stable and you won't
> be able to change it then.

But is this actually a problem here? The current device tree file
will keep working even if the proper driver is there, you just need
to update both the driver and the dts file in order to actually
use the clocks at run-time.

I guess it comes down to the question of whether we want to handle
old kernels with new device trees again, which would be broken here.

	Arnd

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

* Re: [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
  2014-04-09 21:52     ` Olof Johansson
  (?)
@ 2014-04-11  9:07       ` Matthias Brugger
  -1 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-11  9:07 UTC (permalink / raw)
  To: Olof Johansson
  Cc: linux-kernel, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Randy Dunlap, Russell King - ARM Linux,
	Daniel Lezcano, Thomas Gleixner, Thierry Reding,
	Florian Vaussard, Jonathan Cameron, Jason Cooper, Andrew Lunn,
	Silvio F, Heiko Stübner, Sebastian Hesselbarth, devicetree,
	linux-doc, linux-arm-kernel

2014-04-09 23:52 GMT+02:00 Olof Johansson <olof@lixom.net>:
> Hi,
>
> On Wed, Apr 9, 2014 at 12:45 PM, Matthias Brugger
> <matthias.bgg@gmail.com> wrote:
>> This patch adds a clock source and clock event for the timer found
>> on the Mediatek SoCs.
>>
>> The Mediatek General Porpose Timer block provides five 32 bit timers and
>> one 64 bit timer.
>>
>> Two 32 bit timers are used:
>> TIMER1: clock events supporting periodic and oneshot events
>> TIMER2: clock source configured as a free running counter
>>
>> The General Porpose Timer block can be run with two clocks. A 13 MHz system
>> clock and the RTC clock running at 32 KHz. This implementation uses the system
>> clock.
>
> Hm, are you planning on using these on the Cortex-A7-based and newer
> SoCs? On those, the arm generic timers should be available, and you
> might be better off just using those there.

I'm a bit puzzled about the timer naming.
Are the arm generic timers the one used by ARM_ARCH_TIMER, or are they
different ones?

>
> Of course, you'll still need these for the A9-based platforms, so the
> driver might very well be needed anyway. Some of the earlier patches
> seem to be for A7-based systems so I'm not sure what you're primarily
> working on here. :)

I'm working on a Cortex-A7 based platform. But ARM_ARCH_TIMER seems to
get no clocking.
Initializing the timer fails with:
Architected timer frequency not available

That's why I use the SoC timer.

>
>
> -Olof



-- 
motzblog.wordpress.com

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

* Re: [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-11  9:07       ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-11  9:07 UTC (permalink / raw)
  To: Olof Johansson
  Cc: linux-kernel, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Randy Dunlap, Russell King - ARM Linux,
	Daniel Lezcano, Thomas Gleixner, Thierry Reding,
	Florian Vaussard, Jonathan Cameron, Jason Cooper, Andrew Lunn,
	Silvio F, Heiko Stübner, Sebastian Hesselbarth, devicetree,
	linux-doc

2014-04-09 23:52 GMT+02:00 Olof Johansson <olof@lixom.net>:
> Hi,
>
> On Wed, Apr 9, 2014 at 12:45 PM, Matthias Brugger
> <matthias.bgg@gmail.com> wrote:
>> This patch adds a clock source and clock event for the timer found
>> on the Mediatek SoCs.
>>
>> The Mediatek General Porpose Timer block provides five 32 bit timers and
>> one 64 bit timer.
>>
>> Two 32 bit timers are used:
>> TIMER1: clock events supporting periodic and oneshot events
>> TIMER2: clock source configured as a free running counter
>>
>> The General Porpose Timer block can be run with two clocks. A 13 MHz system
>> clock and the RTC clock running at 32 KHz. This implementation uses the system
>> clock.
>
> Hm, are you planning on using these on the Cortex-A7-based and newer
> SoCs? On those, the arm generic timers should be available, and you
> might be better off just using those there.

I'm a bit puzzled about the timer naming.
Are the arm generic timers the one used by ARM_ARCH_TIMER, or are they
different ones?

>
> Of course, you'll still need these for the A9-based platforms, so the
> driver might very well be needed anyway. Some of the earlier patches
> seem to be for A7-based systems so I'm not sure what you're primarily
> working on here. :)

I'm working on a Cortex-A7 based platform. But ARM_ARCH_TIMER seems to
get no clocking.
Initializing the timer fails with:
Architected timer frequency not available

That's why I use the SoC timer.

>
>
> -Olof



-- 
motzblog.wordpress.com

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

* [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-11  9:07       ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-11  9:07 UTC (permalink / raw)
  To: linux-arm-kernel

2014-04-09 23:52 GMT+02:00 Olof Johansson <olof@lixom.net>:
> Hi,
>
> On Wed, Apr 9, 2014 at 12:45 PM, Matthias Brugger
> <matthias.bgg@gmail.com> wrote:
>> This patch adds a clock source and clock event for the timer found
>> on the Mediatek SoCs.
>>
>> The Mediatek General Porpose Timer block provides five 32 bit timers and
>> one 64 bit timer.
>>
>> Two 32 bit timers are used:
>> TIMER1: clock events supporting periodic and oneshot events
>> TIMER2: clock source configured as a free running counter
>>
>> The General Porpose Timer block can be run with two clocks. A 13 MHz system
>> clock and the RTC clock running at 32 KHz. This implementation uses the system
>> clock.
>
> Hm, are you planning on using these on the Cortex-A7-based and newer
> SoCs? On those, the arm generic timers should be available, and you
> might be better off just using those there.

I'm a bit puzzled about the timer naming.
Are the arm generic timers the one used by ARM_ARCH_TIMER, or are they
different ones?

>
> Of course, you'll still need these for the A9-based platforms, so the
> driver might very well be needed anyway. Some of the earlier patches
> seem to be for A7-based systems so I'm not sure what you're primarily
> working on here. :)

I'm working on a Cortex-A7 based platform. But ARM_ARCH_TIMER seems to
get no clocking.
Initializing the timer fails with:
Architected timer frequency not available

That's why I use the SoC timer.

>
>
> -Olof



-- 
motzblog.wordpress.com

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-10  9:01       ` Marc Zyngier
@ 2014-04-11  9:11         ` Matthias Brugger
  -1 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-11  9:11 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Mark Rutland, Andrew Lunn, linux-doc, Thierry Reding,
	heiko.stuebner, Russell King - ARM Linux, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, linux-kernel,
	Silvio F, Kumar

2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
> A couple of things on top of Rob's comments:
>
> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>>> This adds a generic devicetree board file and a dtsi for boards
>>> based on the MT6589 SoCs from Mediatek.
>>>
>>> Apart from the generic parts (gic, clocks) the only component
>>> currently supported are the timers.
>>>
>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>
> [...]
>
>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>> new file mode 100644
>>> index 0000000..c0139ca
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>> @@ -0,0 +1,14 @@
>>> +config ARCH_MEDIATEK
>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>> +       select ARCH_REQUIRE_GPIOLIB
>>
>> Then where is your GPIO driver?
>>
>>> +       select ARM_GIC
>>> +       select CACHE_L2X0
>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
>
> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
> node).

I considered this, but the timer wasn't able to get it's clock frequency:
"Architected timer frequency not available
Division by zero in kernel."

>
>>> +       select HAVE_SMP
>>
>> Not needed now (going into 3.15).
>>
>>> +       select LOCAL_TIMERS if SMP
>
> No, A7 always have the arch timers.
>
> Thanks,
>
>         M.
> --
> Jazz is not dead. It just smells funny.



-- 
motzblog.wordpress.com

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-11  9:11         ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-11  9:11 UTC (permalink / raw)
  To: linux-arm-kernel

2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
> A couple of things on top of Rob's comments:
>
> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>>> This adds a generic devicetree board file and a dtsi for boards
>>> based on the MT6589 SoCs from Mediatek.
>>>
>>> Apart from the generic parts (gic, clocks) the only component
>>> currently supported are the timers.
>>>
>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>
> [...]
>
>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>> new file mode 100644
>>> index 0000000..c0139ca
>>> --- /dev/null
>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>> @@ -0,0 +1,14 @@
>>> +config ARCH_MEDIATEK
>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>> +       select ARCH_REQUIRE_GPIOLIB
>>
>> Then where is your GPIO driver?
>>
>>> +       select ARM_GIC
>>> +       select CACHE_L2X0
>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
>
> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
> node).

I considered this, but the timer wasn't able to get it's clock frequency:
"Architected timer frequency not available
Division by zero in kernel."

>
>>> +       select HAVE_SMP
>>
>> Not needed now (going into 3.15).
>>
>>> +       select LOCAL_TIMERS if SMP
>
> No, A7 always have the arch timers.
>
> Thanks,
>
>         M.
> --
> Jazz is not dead. It just smells funny.



-- 
motzblog.wordpress.com

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

* Re: [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
  2014-04-11  9:07       ` Matthias Brugger
  (?)
@ 2014-04-11  9:21         ` Arnd Bergmann
  -1 siblings, 0 replies; 74+ messages in thread
From: Arnd Bergmann @ 2014-04-11  9:21 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: Olof Johansson, linux-kernel, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Randy Dunlap,
	Russell King - ARM Linux, Daniel Lezcano, Thomas Gleixner,
	Thierry Reding, Florian Vaussard, Jonathan Cameron, Jason Cooper,
	Andrew Lunn, Silvio F, Heiko Stübner, Sebastian Hesselbarth,
	devicetree, linux-doc, linux-arm-kernel

On Friday 11 April 2014 11:07:35 Matthias Brugger wrote:
> >
> > Of course, you'll still need these for the A9-based platforms, so the
> > driver might very well be needed anyway. Some of the earlier patches
> > seem to be for A7-based systems so I'm not sure what you're primarily
> > working on here. 
> 
> I'm working on a Cortex-A7 based platform. But ARM_ARCH_TIMER seems to
> get no clocking.
> Initializing the timer fails with:
> Architected timer frequency not available
> 
> That's why I use the SoC timer.

Are you sure you're not just missing a "clock-frequency" property
in your DT node for the timer?

	Arnd

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

* Re: [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-11  9:21         ` Arnd Bergmann
  0 siblings, 0 replies; 74+ messages in thread
From: Arnd Bergmann @ 2014-04-11  9:21 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: Olof Johansson, linux-kernel, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Randy Dunlap,
	Russell King - ARM Linux, Daniel Lezcano, Thomas Gleixner,
	Thierry Reding, Florian Vaussard, Jonathan Cameron, Jason Cooper,
	Andrew Lunn, Silvio F, Heiko Stübner, Sebastian Hesselbarth,
	devicetree, linux-doc

On Friday 11 April 2014 11:07:35 Matthias Brugger wrote:
> >
> > Of course, you'll still need these for the A9-based platforms, so the
> > driver might very well be needed anyway. Some of the earlier patches
> > seem to be for A7-based systems so I'm not sure what you're primarily
> > working on here. 
> 
> I'm working on a Cortex-A7 based platform. But ARM_ARCH_TIMER seems to
> get no clocking.
> Initializing the timer fails with:
> Architected timer frequency not available
> 
> That's why I use the SoC timer.

Are you sure you're not just missing a "clock-frequency" property
in your DT node for the timer?

	Arnd

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

* [PATCH 1/4] clocksource: Add support for the Mediatek SoCs
@ 2014-04-11  9:21         ` Arnd Bergmann
  0 siblings, 0 replies; 74+ messages in thread
From: Arnd Bergmann @ 2014-04-11  9:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 11 April 2014 11:07:35 Matthias Brugger wrote:
> >
> > Of course, you'll still need these for the A9-based platforms, so the
> > driver might very well be needed anyway. Some of the earlier patches
> > seem to be for A7-based systems so I'm not sure what you're primarily
> > working on here. 
> 
> I'm working on a Cortex-A7 based platform. But ARM_ARCH_TIMER seems to
> get no clocking.
> Initializing the timer fails with:
> Architected timer frequency not available
> 
> That's why I use the SoC timer.

Are you sure you're not just missing a "clock-frequency" property
in your DT node for the timer?

	Arnd

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-11  9:11         ` Matthias Brugger
@ 2014-04-11  9:43           ` Marc Zyngier
  -1 siblings, 0 replies; 74+ messages in thread
From: Marc Zyngier @ 2014-04-11  9:43 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: Mark Rutland, Andrew Lunn, linux-doc, Thierry Reding,
	heiko.stuebner, Russell King - ARM Linux, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, linux-kernel,
	Silvio F, Kumar

On 11/04/14 10:11, Matthias Brugger wrote:
> 2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>> A couple of things on top of Rob's comments:
>>
>> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
>>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>>>> This adds a generic devicetree board file and a dtsi for boards
>>>> based on the MT6589 SoCs from Mediatek.
>>>>
>>>> Apart from the generic parts (gic, clocks) the only component
>>>> currently supported are the timers.
>>>>
>>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>
>> [...]
>>
>>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>>> new file mode 100644
>>>> index 0000000..c0139ca
>>>> --- /dev/null
>>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>>> @@ -0,0 +1,14 @@
>>>> +config ARCH_MEDIATEK
>>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>>> +       select ARCH_REQUIRE_GPIOLIB
>>>
>>> Then where is your GPIO driver?
>>>
>>>> +       select ARM_GIC
>>>> +       select CACHE_L2X0
>>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
>>
>> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
>> node).
> 
> I considered this, but the timer wasn't able to get it's clock frequency:
> "Architected timer frequency not available
> Division by zero in kernel."

This is because your bootloader/firmware is utterly broken, and doesn't
set CNTFRQ (it must be set on all CPUs, from secure mode). As a
*workaround*, you can set the timer frequency in the timer node, but
that's just a hack, and will prevent virtual machines from running on
such hardware.

	M.
-- 
Jazz is not dead. It just smells funny...

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-11  9:43           ` Marc Zyngier
  0 siblings, 0 replies; 74+ messages in thread
From: Marc Zyngier @ 2014-04-11  9:43 UTC (permalink / raw)
  To: linux-arm-kernel

On 11/04/14 10:11, Matthias Brugger wrote:
> 2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>> A couple of things on top of Rob's comments:
>>
>> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
>>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>>>> This adds a generic devicetree board file and a dtsi for boards
>>>> based on the MT6589 SoCs from Mediatek.
>>>>
>>>> Apart from the generic parts (gic, clocks) the only component
>>>> currently supported are the timers.
>>>>
>>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>
>> [...]
>>
>>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>>> new file mode 100644
>>>> index 0000000..c0139ca
>>>> --- /dev/null
>>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>>> @@ -0,0 +1,14 @@
>>>> +config ARCH_MEDIATEK
>>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>>> +       select ARCH_REQUIRE_GPIOLIB
>>>
>>> Then where is your GPIO driver?
>>>
>>>> +       select ARM_GIC
>>>> +       select CACHE_L2X0
>>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
>>
>> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
>> node).
> 
> I considered this, but the timer wasn't able to get it's clock frequency:
> "Architected timer frequency not available
> Division by zero in kernel."

This is because your bootloader/firmware is utterly broken, and doesn't
set CNTFRQ (it must be set on all CPUs, from secure mode). As a
*workaround*, you can set the timer frequency in the timer node, but
that's just a hack, and will prevent virtual machines from running on
such hardware.

	M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-11  9:43           ` Marc Zyngier
@ 2014-04-11  9:53             ` Maxime Ripard
  -1 siblings, 0 replies; 74+ messages in thread
From: Maxime Ripard @ 2014-04-11  9:53 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Mark Rutland, Andrew Lunn, linux-doc, Thierry Reding,
	heiko.stuebner, Russell King - ARM Linux, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Matthias Brugger, Thomas Gleixner, linux-arm-kernel,
	Randy Dunlap, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 2290 bytes --]

On Fri, Apr 11, 2014 at 10:43:30AM +0100, Marc Zyngier wrote:
> On 11/04/14 10:11, Matthias Brugger wrote:
> > 2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
> >> A couple of things on top of Rob's comments:
> >>
> >> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
> >>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
> >>>> This adds a generic devicetree board file and a dtsi for boards
> >>>> based on the MT6589 SoCs from Mediatek.
> >>>>
> >>>> Apart from the generic parts (gic, clocks) the only component
> >>>> currently supported are the timers.
> >>>>
> >>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> >>
> >> [...]
> >>
> >>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> >>>> new file mode 100644
> >>>> index 0000000..c0139ca
> >>>> --- /dev/null
> >>>> +++ b/arch/arm/mach-mediatek/Kconfig
> >>>> @@ -0,0 +1,14 @@
> >>>> +config ARCH_MEDIATEK
> >>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
> >>>> +       select ARCH_REQUIRE_GPIOLIB
> >>>
> >>> Then where is your GPIO driver?
> >>>
> >>>> +       select ARM_GIC
> >>>> +       select CACHE_L2X0
> >>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
> >>
> >> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
> >> node).
> > 
> > I considered this, but the timer wasn't able to get it's clock frequency:
> > "Architected timer frequency not available
> > Division by zero in kernel."
> 
> This is because your bootloader/firmware is utterly broken, and doesn't
> set CNTFRQ (it must be set on all CPUs, from secure mode). As a
> *workaround*, you can set the timer frequency in the timer node, but
> that's just a hack, and will prevent virtual machines from running on
> such hardware.

Is it?

From what I understood from ARM's ARM, CNTFRQ must be set during the
system boot, but even though the arch timer driver can fetch the
frequency from clock-frequency, I don't see anywhere that it actually
writes to CNTFRQ whatever it retrieved.

But I'm probably missing something here...

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-11  9:53             ` Maxime Ripard
  0 siblings, 0 replies; 74+ messages in thread
From: Maxime Ripard @ 2014-04-11  9:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 11, 2014 at 10:43:30AM +0100, Marc Zyngier wrote:
> On 11/04/14 10:11, Matthias Brugger wrote:
> > 2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
> >> A couple of things on top of Rob's comments:
> >>
> >> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
> >>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
> >>>> This adds a generic devicetree board file and a dtsi for boards
> >>>> based on the MT6589 SoCs from Mediatek.
> >>>>
> >>>> Apart from the generic parts (gic, clocks) the only component
> >>>> currently supported are the timers.
> >>>>
> >>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
> >>
> >> [...]
> >>
> >>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> >>>> new file mode 100644
> >>>> index 0000000..c0139ca
> >>>> --- /dev/null
> >>>> +++ b/arch/arm/mach-mediatek/Kconfig
> >>>> @@ -0,0 +1,14 @@
> >>>> +config ARCH_MEDIATEK
> >>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
> >>>> +       select ARCH_REQUIRE_GPIOLIB
> >>>
> >>> Then where is your GPIO driver?
> >>>
> >>>> +       select ARM_GIC
> >>>> +       select CACHE_L2X0
> >>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
> >>
> >> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
> >> node).
> > 
> > I considered this, but the timer wasn't able to get it's clock frequency:
> > "Architected timer frequency not available
> > Division by zero in kernel."
> 
> This is because your bootloader/firmware is utterly broken, and doesn't
> set CNTFRQ (it must be set on all CPUs, from secure mode). As a
> *workaround*, you can set the timer frequency in the timer node, but
> that's just a hack, and will prevent virtual machines from running on
> such hardware.

Is it?

>From what I understood from ARM's ARM, CNTFRQ must be set during the
system boot, but even though the arch timer driver can fetch the
frequency from clock-frequency, I don't see anywhere that it actually
writes to CNTFRQ whatever it retrieved.

But I'm probably missing something here...

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140411/b636ad7c/attachment.sig>

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-11  9:43           ` Marc Zyngier
@ 2014-04-15 16:09             ` Matthias Brugger
  -1 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-15 16:09 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Mark Rutland, Andrew Lunn, linux-doc, Thierry Reding,
	heiko.stuebner, Russell King - ARM Linux, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, linux-kernel,
	Silvio F, Kumar

2014-04-11 11:43 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
> On 11/04/14 10:11, Matthias Brugger wrote:
>> 2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>>> A couple of things on top of Rob's comments:
>>>
>>> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
>>>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>>>>> This adds a generic devicetree board file and a dtsi for boards
>>>>> based on the MT6589 SoCs from Mediatek.
>>>>>
>>>>> Apart from the generic parts (gic, clocks) the only component
>>>>> currently supported are the timers.
>>>>>
>>>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>>
>>> [...]
>>>
>>>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>>>> new file mode 100644
>>>>> index 0000000..c0139ca
>>>>> --- /dev/null
>>>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>>>> @@ -0,0 +1,14 @@
>>>>> +config ARCH_MEDIATEK
>>>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>>>> +       select ARCH_REQUIRE_GPIOLIB
>>>>
>>>> Then where is your GPIO driver?
>>>>
>>>>> +       select ARM_GIC
>>>>> +       select CACHE_L2X0
>>>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
>>>
>>> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
>>> node).
>>
>> I considered this, but the timer wasn't able to get it's clock frequency:
>> "Architected timer frequency not available
>> Division by zero in kernel."
>
> This is because your bootloader/firmware is utterly broken, and doesn't
> set CNTFRQ (it must be set on all CPUs, from secure mode). As a
> *workaround*, you can set the timer frequency in the timer node, but
> that's just a hack, and will prevent virtual machines from running on
> such hardware.

The last days I tried to get the ARM_ARCH_TIMER working, but I wasn't
able to do so.
I set the frequency in the DT node.
But reading CNTP_TVAL at the end of arch_timer_init, it always returns
the same value.
When reading CNTPCT at the same place, returns zero.
As far as I understand CNTPCT will be always incremented, am I right?

Consequently, when calling mdelay in arch_timer_init the system hangs.

So can it be, that the timers are not working due to a screwed up chip
design? Or do I miss something here?

>
>         M.
> --
> Jazz is not dead. It just smells funny...



-- 
motzblog.wordpress.com

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-15 16:09             ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-04-15 16:09 UTC (permalink / raw)
  To: linux-arm-kernel

2014-04-11 11:43 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
> On 11/04/14 10:11, Matthias Brugger wrote:
>> 2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>>> A couple of things on top of Rob's comments:
>>>
>>> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
>>>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>>>>> This adds a generic devicetree board file and a dtsi for boards
>>>>> based on the MT6589 SoCs from Mediatek.
>>>>>
>>>>> Apart from the generic parts (gic, clocks) the only component
>>>>> currently supported are the timers.
>>>>>
>>>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>>
>>> [...]
>>>
>>>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>>>> new file mode 100644
>>>>> index 0000000..c0139ca
>>>>> --- /dev/null
>>>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>>>> @@ -0,0 +1,14 @@
>>>>> +config ARCH_MEDIATEK
>>>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>>>> +       select ARCH_REQUIRE_GPIOLIB
>>>>
>>>> Then where is your GPIO driver?
>>>>
>>>>> +       select ARM_GIC
>>>>> +       select CACHE_L2X0
>>>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
>>>
>>> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
>>> node).
>>
>> I considered this, but the timer wasn't able to get it's clock frequency:
>> "Architected timer frequency not available
>> Division by zero in kernel."
>
> This is because your bootloader/firmware is utterly broken, and doesn't
> set CNTFRQ (it must be set on all CPUs, from secure mode). As a
> *workaround*, you can set the timer frequency in the timer node, but
> that's just a hack, and will prevent virtual machines from running on
> such hardware.

The last days I tried to get the ARM_ARCH_TIMER working, but I wasn't
able to do so.
I set the frequency in the DT node.
But reading CNTP_TVAL at the end of arch_timer_init, it always returns
the same value.
When reading CNTPCT at the same place, returns zero.
As far as I understand CNTPCT will be always incremented, am I right?

Consequently, when calling mdelay in arch_timer_init the system hangs.

So can it be, that the timers are not working due to a screwed up chip
design? Or do I miss something here?

>
>         M.
> --
> Jazz is not dead. It just smells funny...



-- 
motzblog.wordpress.com

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-15 16:09             ` Matthias Brugger
@ 2014-04-15 16:40               ` Marc Zyngier
  -1 siblings, 0 replies; 74+ messages in thread
From: Marc Zyngier @ 2014-04-15 16:40 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: Mark Rutland, Andrew Lunn, linux-doc, Thierry Reding,
	heiko.stuebner, Russell King - ARM Linux, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, linux-kernel,
	Silvio F, Kumar

On 15/04/14 17:09, Matthias Brugger wrote:
> 2014-04-11 11:43 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>> On 11/04/14 10:11, Matthias Brugger wrote:
>>> 2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>>>> A couple of things on top of Rob's comments:
>>>>
>>>> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
>>>>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>>>>>> This adds a generic devicetree board file and a dtsi for boards
>>>>>> based on the MT6589 SoCs from Mediatek.
>>>>>>
>>>>>> Apart from the generic parts (gic, clocks) the only component
>>>>>> currently supported are the timers.
>>>>>>
>>>>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>>>
>>>> [...]
>>>>
>>>>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>>>>> new file mode 100644
>>>>>> index 0000000..c0139ca
>>>>>> --- /dev/null
>>>>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>>>>> @@ -0,0 +1,14 @@
>>>>>> +config ARCH_MEDIATEK
>>>>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>>>>> +       select ARCH_REQUIRE_GPIOLIB
>>>>>
>>>>> Then where is your GPIO driver?
>>>>>
>>>>>> +       select ARM_GIC
>>>>>> +       select CACHE_L2X0
>>>>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
>>>>
>>>> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
>>>> node).
>>>
>>> I considered this, but the timer wasn't able to get it's clock frequency:
>>> "Architected timer frequency not available
>>> Division by zero in kernel."
>>
>> This is because your bootloader/firmware is utterly broken, and doesn't
>> set CNTFRQ (it must be set on all CPUs, from secure mode). As a
>> *workaround*, you can set the timer frequency in the timer node, but
>> that's just a hack, and will prevent virtual machines from running on
>> such hardware.
> 
> The last days I tried to get the ARM_ARCH_TIMER working, but I wasn't
> able to do so.
> I set the frequency in the DT node.
> But reading CNTP_TVAL at the end of arch_timer_init, it always returns
> the same value.
> When reading CNTPCT at the same place, returns zero.
> As far as I understand CNTPCT will be always incremented, am I right?
> 
> Consequently, when calling mdelay in arch_timer_init the system hangs.
> 
> So can it be, that the timers are not working due to a screwed up chip
> design? Or do I miss something here?

That would indicate that the clock that feeds into the timer is gated.
Other SoC vendors have done the same thing. Do you have access to
documentation describing the clock tree?

Of course, a broken design is always possible, but let's not think of
the worse just yet... ;-)

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-04-15 16:40               ` Marc Zyngier
  0 siblings, 0 replies; 74+ messages in thread
From: Marc Zyngier @ 2014-04-15 16:40 UTC (permalink / raw)
  To: linux-arm-kernel

On 15/04/14 17:09, Matthias Brugger wrote:
> 2014-04-11 11:43 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>> On 11/04/14 10:11, Matthias Brugger wrote:
>>> 2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>>>> A couple of things on top of Rob's comments:
>>>>
>>>> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
>>>>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>>>>>> This adds a generic devicetree board file and a dtsi for boards
>>>>>> based on the MT6589 SoCs from Mediatek.
>>>>>>
>>>>>> Apart from the generic parts (gic, clocks) the only component
>>>>>> currently supported are the timers.
>>>>>>
>>>>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>>>
>>>> [...]
>>>>
>>>>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>>>>> new file mode 100644
>>>>>> index 0000000..c0139ca
>>>>>> --- /dev/null
>>>>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>>>>> @@ -0,0 +1,14 @@
>>>>>> +config ARCH_MEDIATEK
>>>>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>>>>> +       select ARCH_REQUIRE_GPIOLIB
>>>>>
>>>>> Then where is your GPIO driver?
>>>>>
>>>>>> +       select ARM_GIC
>>>>>> +       select CACHE_L2X0
>>>>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
>>>>
>>>> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
>>>> node).
>>>
>>> I considered this, but the timer wasn't able to get it's clock frequency:
>>> "Architected timer frequency not available
>>> Division by zero in kernel."
>>
>> This is because your bootloader/firmware is utterly broken, and doesn't
>> set CNTFRQ (it must be set on all CPUs, from secure mode). As a
>> *workaround*, you can set the timer frequency in the timer node, but
>> that's just a hack, and will prevent virtual machines from running on
>> such hardware.
> 
> The last days I tried to get the ARM_ARCH_TIMER working, but I wasn't
> able to do so.
> I set the frequency in the DT node.
> But reading CNTP_TVAL at the end of arch_timer_init, it always returns
> the same value.
> When reading CNTPCT at the same place, returns zero.
> As far as I understand CNTPCT will be always incremented, am I right?
> 
> Consequently, when calling mdelay in arch_timer_init the system hangs.
> 
> So can it be, that the timers are not working due to a screwed up chip
> design? Or do I miss something here?

That would indicate that the clock that feeds into the timer is gated.
Other SoC vendors have done the same thing. Do you have access to
documentation describing the clock tree?

Of course, a broken design is always possible, but let's not think of
the worse just yet... ;-)

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
  2014-04-15 16:40               ` Marc Zyngier
@ 2014-05-04 12:50                 ` Matthias Brugger
  -1 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-05-04 12:50 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Mark Rutland, Andrew Lunn, linux-doc, Thierry Reding,
	heiko.stuebner, Russell King - ARM Linux, Daniel Lezcano,
	Florian Vaussard, Sebastian Hesselbarth, devicetree,
	Jason Cooper, Pawel Moll, Ian Campbell, Rob Herring,
	Thomas Gleixner, linux-arm-kernel, Randy Dunlap, linux-kernel,
	Silvio F, Kumar

2014-04-15 18:40 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
> On 15/04/14 17:09, Matthias Brugger wrote:
>> 2014-04-11 11:43 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>>> On 11/04/14 10:11, Matthias Brugger wrote:
>>>> 2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>>>>> A couple of things on top of Rob's comments:
>>>>>
>>>>> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
>>>>>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>>>>>>> This adds a generic devicetree board file and a dtsi for boards
>>>>>>> based on the MT6589 SoCs from Mediatek.
>>>>>>>
>>>>>>> Apart from the generic parts (gic, clocks) the only component
>>>>>>> currently supported are the timers.
>>>>>>>
>>>>>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>>>>
>>>>> [...]
>>>>>
>>>>>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>>>>>> new file mode 100644
>>>>>>> index 0000000..c0139ca
>>>>>>> --- /dev/null
>>>>>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>>>>>> @@ -0,0 +1,14 @@
>>>>>>> +config ARCH_MEDIATEK
>>>>>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>>>>>> +       select ARCH_REQUIRE_GPIOLIB
>>>>>>
>>>>>> Then where is your GPIO driver?
>>>>>>
>>>>>>> +       select ARM_GIC
>>>>>>> +       select CACHE_L2X0
>>>>>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
>>>>>
>>>>> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
>>>>> node).
>>>>
>>>> I considered this, but the timer wasn't able to get it's clock frequency:
>>>> "Architected timer frequency not available
>>>> Division by zero in kernel."
>>>
>>> This is because your bootloader/firmware is utterly broken, and doesn't
>>> set CNTFRQ (it must be set on all CPUs, from secure mode). As a
>>> *workaround*, you can set the timer frequency in the timer node, but
>>> that's just a hack, and will prevent virtual machines from running on
>>> such hardware.
>>
>> The last days I tried to get the ARM_ARCH_TIMER working, but I wasn't
>> able to do so.
>> I set the frequency in the DT node.
>> But reading CNTP_TVAL at the end of arch_timer_init, it always returns
>> the same value.
>> When reading CNTPCT at the same place, returns zero.
>> As far as I understand CNTPCT will be always incremented, am I right?
>>
>> Consequently, when calling mdelay in arch_timer_init the system hangs.
>>
>> So can it be, that the timers are not working due to a screwed up chip
>> design? Or do I miss something here?
>
> That would indicate that the clock that feeds into the timer is gated.
> Other SoC vendors have done the same thing. Do you have access to
> documentation describing the clock tree?
>
> Of course, a broken design is always possible, but let's not think of
> the worse just yet... ;-)

The clock tree documentation is really spare but I tried to made some
changes to the registers which controls the clock gates and the DCMs.
But with no luck.
So for me it looks like a broken design :(
It looks like we need the global timer from mediatek.

I will try to update the patch series with the comments given and send
a v2 the next days.

>
> Thanks,
>
>         M.
> --
> Jazz is not dead. It just smells funny...



-- 
motzblog.wordpress.com

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

* [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards
@ 2014-05-04 12:50                 ` Matthias Brugger
  0 siblings, 0 replies; 74+ messages in thread
From: Matthias Brugger @ 2014-05-04 12:50 UTC (permalink / raw)
  To: linux-arm-kernel

2014-04-15 18:40 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
> On 15/04/14 17:09, Matthias Brugger wrote:
>> 2014-04-11 11:43 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>>> On 11/04/14 10:11, Matthias Brugger wrote:
>>>> 2014-04-10 11:01 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>>>>> A couple of things on top of Rob's comments:
>>>>>
>>>>> On Wed, Apr 09 2014 at 10:50:33 pm BST, Rob Herring <robherring2@gmail.com> wrote:
>>>>>> On Wed, Apr 9, 2014 at 2:45 PM, Matthias Brugger <matthias.bgg@gmail.com> wrote:
>>>>>>> This adds a generic devicetree board file and a dtsi for boards
>>>>>>> based on the MT6589 SoCs from Mediatek.
>>>>>>>
>>>>>>> Apart from the generic parts (gic, clocks) the only component
>>>>>>> currently supported are the timers.
>>>>>>>
>>>>>>> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
>>>>>
>>>>> [...]
>>>>>
>>>>>>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>>>>>>> new file mode 100644
>>>>>>> index 0000000..c0139ca
>>>>>>> --- /dev/null
>>>>>>> +++ b/arch/arm/mach-mediatek/Kconfig
>>>>>>> @@ -0,0 +1,14 @@
>>>>>>> +config ARCH_MEDIATEK
>>>>>>> +       bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
>>>>>>> +       select ARCH_REQUIRE_GPIOLIB
>>>>>>
>>>>>> Then where is your GPIO driver?
>>>>>>
>>>>>>> +       select ARM_GIC
>>>>>>> +       select CACHE_L2X0
>>>>>>> +       select HAVE_ARM_TWD if LOCAL_TIMERS
>>>>>
>>>>> Hell no! ;-) ARM_ARCH_TIMER is the way (please also add the missing
>>>>> node).
>>>>
>>>> I considered this, but the timer wasn't able to get it's clock frequency:
>>>> "Architected timer frequency not available
>>>> Division by zero in kernel."
>>>
>>> This is because your bootloader/firmware is utterly broken, and doesn't
>>> set CNTFRQ (it must be set on all CPUs, from secure mode). As a
>>> *workaround*, you can set the timer frequency in the timer node, but
>>> that's just a hack, and will prevent virtual machines from running on
>>> such hardware.
>>
>> The last days I tried to get the ARM_ARCH_TIMER working, but I wasn't
>> able to do so.
>> I set the frequency in the DT node.
>> But reading CNTP_TVAL at the end of arch_timer_init, it always returns
>> the same value.
>> When reading CNTPCT at the same place, returns zero.
>> As far as I understand CNTPCT will be always incremented, am I right?
>>
>> Consequently, when calling mdelay in arch_timer_init the system hangs.
>>
>> So can it be, that the timers are not working due to a screwed up chip
>> design? Or do I miss something here?
>
> That would indicate that the clock that feeds into the timer is gated.
> Other SoC vendors have done the same thing. Do you have access to
> documentation describing the clock tree?
>
> Of course, a broken design is always possible, but let's not think of
> the worse just yet... ;-)

The clock tree documentation is really spare but I tried to made some
changes to the registers which controls the clock gates and the DCMs.
But with no luck.
So for me it looks like a broken design :(
It looks like we need the global timer from mediatek.

I will try to update the patch series with the comments given and send
a v2 the next days.

>
> Thanks,
>
>         M.
> --
> Jazz is not dead. It just smells funny...



-- 
motzblog.wordpress.com

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

end of thread, other threads:[~2014-05-04 12:50 UTC | newest]

Thread overview: 74+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-09 19:45 [PATCH 0/4] arm: Add basic support for Mediatek Cortex-A7 SoCs Matthias Brugger
2014-04-09 19:45 ` Matthias Brugger
2014-04-09 19:45 ` [PATCH 1/4] clocksource: Add support for the Mediatek SoCs Matthias Brugger
2014-04-09 19:45   ` Matthias Brugger
2014-04-09 19:45   ` Matthias Brugger
2014-04-09 20:58   ` Stephen Boyd
2014-04-09 20:58     ` Stephen Boyd
2014-04-09 20:58     ` Stephen Boyd
2014-04-09 21:08   ` Gregory CLEMENT
2014-04-09 21:08     ` Gregory CLEMENT
2014-04-09 21:08     ` Gregory CLEMENT
2014-04-09 21:52   ` Olof Johansson
2014-04-09 21:52     ` Olof Johansson
2014-04-09 21:52     ` Olof Johansson
2014-04-11  9:07     ` Matthias Brugger
2014-04-11  9:07       ` Matthias Brugger
2014-04-11  9:07       ` Matthias Brugger
2014-04-11  9:21       ` Arnd Bergmann
2014-04-11  9:21         ` Arnd Bergmann
2014-04-11  9:21         ` Arnd Bergmann
2014-04-09 19:45 ` [PATCH 2/4] dt-bindings: add mtk-timer bindings Matthias Brugger
2014-04-09 19:45   ` Matthias Brugger
2014-04-09 19:45   ` Matthias Brugger
2014-04-09 20:56   ` Gregory CLEMENT
2014-04-09 20:56     ` Gregory CLEMENT
2014-04-09 19:45 ` [PATCH 3/4] arm: add basic support for Mediatek MT6589 boards Matthias Brugger
2014-04-09 19:45   ` Matthias Brugger
2014-04-09 20:26   ` Gregory CLEMENT
2014-04-09 20:26     ` Gregory CLEMENT
2014-04-10  8:29     ` Matthias Brugger
2014-04-10  8:29       ` Matthias Brugger
2014-04-10  8:29       ` Matthias Brugger
2014-04-10  8:46       ` Gregory CLEMENT
2014-04-10  8:46         ` Gregory CLEMENT
2014-04-10  8:46         ` Gregory CLEMENT
2014-04-10  9:34         ` Heiko Stübner
2014-04-10  9:34           ` Heiko Stübner
2014-04-10  9:34           ` Heiko Stübner
2014-04-10  9:36         ` Arnd Bergmann
2014-04-10  9:36           ` Arnd Bergmann
2014-04-10  9:36           ` Arnd Bergmann
2014-04-09 21:50   ` Rob Herring
2014-04-09 21:50     ` Rob Herring
2014-04-09 21:50     ` Rob Herring
2014-04-10  9:01     ` Marc Zyngier
2014-04-10  9:01       ` Marc Zyngier
2014-04-10  9:01       ` Marc Zyngier
2014-04-11  9:11       ` Matthias Brugger
2014-04-11  9:11         ` Matthias Brugger
2014-04-11  9:43         ` Marc Zyngier
2014-04-11  9:43           ` Marc Zyngier
2014-04-11  9:53           ` Maxime Ripard
2014-04-11  9:53             ` Maxime Ripard
2014-04-15 16:09           ` Matthias Brugger
2014-04-15 16:09             ` Matthias Brugger
2014-04-15 16:40             ` Marc Zyngier
2014-04-15 16:40               ` Marc Zyngier
2014-05-04 12:50               ` Matthias Brugger
2014-05-04 12:50                 ` Matthias Brugger
2014-04-10  7:36   ` Arnd Bergmann
2014-04-10  7:36     ` Arnd Bergmann
2014-04-10  7:36     ` Arnd Bergmann
2014-04-10  9:15     ` Matthias Brugger
2014-04-10  9:15       ` Matthias Brugger
2014-04-09 19:45 ` [PATCH 4/4] arm: mediatek: Add earlyprintk support for MT6589 Matthias Brugger
2014-04-09 19:45   ` Matthias Brugger
2014-04-09 20:54   ` Gregory CLEMENT
2014-04-09 20:54     ` Gregory CLEMENT
2014-04-09 21:39   ` Rob Herring
2014-04-09 21:39     ` Rob Herring
2014-04-09 21:39     ` Rob Herring
2014-04-10  8:22     ` Matthias Brugger
2014-04-10  8:22       ` Matthias Brugger
2014-04-10  8:22       ` Matthias Brugger

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.