Skip to contentSkip to conversation

arm: Add basic support for Mediatek Cortex-A7 SoCs

PATCH Superseded Matthias Brugger 2 participants 13 messages May 14, 2014 – May 15, 2014

Subsystems (5)

v4 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Matthias Brugger

author maintainer
#0 lore raw

v4 cover arm: Add basic support for Mediatek Cortex-A7 SoCs

Fourth round for the Mediatek basic support patches.

I added the clock-names for the timer input clocks, although I don't use the name to retrive the clock from the DT. I found this behaviour in other drivers like the arm,sp804.

In the DTSI I changed the label of the clocks to reflect the name in the SoC but left the node name as dummy13m and dummy32k to reflect that up to now, the clocks are not integrated in the common clock framework.

I kept the minimal machine file, for the reasons Maxime mentioned [1].

[1] http://article.gmane.org/gmane.linux.documentation/23650

---
This patch set adds basic support for the Mediatek Cortex-A7 SoCs. Support is quite basic, as the only component working up to now are the timers.

The patch series is build against torvalds/master tree.

Changes for v4:
1. Clocksource timer
- use cpu_possible_mask

2. Timer DT bindings
- Delete comments about the frequency of the clocks
- Add clock-names for the input clocks

3. Basic SoC support
- add clock-names for the timer
- rename the label of the clocks nodes

Changes for v3:
1. Clocksource timer
- Set cpu_mask_all and irq in clock_event_device
- Use device private structure for driver specific values

2. Timer DT bindings
- Define order of the clock phandles
- Fix typos

3. Basic SoC support
- DTS: set gic to a15-gic
- DTS: order by physical address
- Remove call to dt_init function

Changes for v2:
1. Clocksource timer
- Delete unused parts for sched_clock_source
- Use irq_request instead of setup_irq
- Remove unused SMP parts
- Fix some style issues
- use of_address_to resource and request_mem_region
- delete use of named clock
- select CLKSRC_MMIO in driver Kconfig

2. DT bindings
- delete named clock bindings

3. Basic SoC support
- Clean-up Kconfig
- Add documentation of the SoC compatible property
- DTS: rename SoC file to mt6589.dts
- DTS: Delete not present cache controller
- DTS: Add missing GICv2 properties
- DTS: Change clock names
- DTS: Add Aquaris5 board

4. Add earlyprintk
- patch droped until serial driver is available

5. Add support for Aquaris5 mobile phone

---

Matthias Brugger (6):
clocksource: Add support for the Mediatek SoCs
dt-bindings: add mtk-timer bindings
vendor-prefixes: add prefix for Mediaktek Inc.
arm: add basic support for Mediatek MT6589 boards
dt-bindings: add documentation for Mediatek SoC
arm: mediatek: add dts for Aquaris5 mobile phone

 .../devicetree/bindings/arm/mediatek-mt65xx.txt    |   8 +
 .../bindings/timer/mediatek,mtk-timer.txt          |  18 ++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 arch/arm/Kconfig                                   |   2 +
 arch/arm/Makefile                                  |   1 +
 arch/arm/boot/dts/mt6589-aquaris5.dts              |  25 ++
 arch/arm/boot/dts/mt6589.dtsi                      |  94 ++++++++
 arch/arm/mach-mediatek/Kconfig                     |   6 +
 arch/arm/mach-mediatek/Makefile                    |   1 +
 arch/arm/mach-mediatek/mediatek.c                  |  32 +++
 drivers/clocksource/Kconfig                        |   4 +
 drivers/clocksource/Makefile                       |   1 +
 drivers/clocksource/mtk_timer.c                    | 263 +++++++++++++++++++++
 13 files changed, 456 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt
 create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
 create mode 100644 arch/arm/boot/dts/mt6589-aquaris5.dts
 create mode 100644 arch/arm/boot/dts/mt6589.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
 create mode 100644 drivers/clocksource/mtk_timer.c
Signature · 1 line
1.8.1.2
author maintainer
#1 lore raw

PATCH v4 1/6 clocksource: Add support for the Mediatek SoCs

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.

---
 drivers/clocksource/Kconfig     |   4 +
 drivers/clocksource/Makefile    |   1 +
 drivers/clocksource/mtk_timer.c | 263 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 268 insertions(+)
 create mode 100644 drivers/clocksource/mtk_timer.c
drivers/clocksource/Kconfig +4 -0
index 96918e1..1f73740 100644
@@ -144,6 +144,10 @@ config VF_PIT_TIMER
 config SYS_SUPPORTS_SH_CMT
         bool
 
+config MTK_TIMER
+	select CLKSRC_MMIO
+	bool
+
 config SYS_SUPPORTS_SH_MTU2
         bool
 
drivers/clocksource/Makefile +1 -0
index 98cb6c5..619d302 100644
@@ -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
drivers/clocksource/mtk_timer.c new file +263 -0

263 lines not on this page · raw message

Signature · 1 line
1.8.1.2
author maintainer
#5 lore raw

PATCH v4 2/6 dt-bindings: add mtk-timer bindings

In reply to Matthias Brugger

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

---
 .../devicetree/bindings/timer/mediatek,mtk-timer.txt   | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +18 -0
new file mode 100644
index 0000000..938adf6
@@ -0,0 +1,18 @@
+Mediatek MT6589, MT6577 and MT6572 Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "mediatek,mtk6589-timer"
+- reg: Should contain location and length for timers register.
+- clocks: Clocks driving the timer hardware. This list shoud include two
+	clocks. The order is system clock and as second clock the 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 = "system-clk", "rtc-clk";
+	};
Signature · 1 line
1.8.1.2
author maintainer
#9 lore raw

PATCH v4 3/6 vendor-prefixes: add prefix for Mediaktek Inc.

In reply to Matthias Brugger
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index abc3080..73f9e4c 100644
@@ -75,6 +75,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
Signature · 1 line
1.8.1.2
author maintainer
#10 lore raw

PATCH v4 4/6 arm: add basic support for Mediatek MT6589 boards

In reply to Matthias Brugger

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

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

---
 arch/arm/Kconfig                  |  2 +
 arch/arm/Makefile                 |  1 +
 arch/arm/boot/dts/mt6589.dtsi     | 94 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-mediatek/Kconfig    |  6 +++
 arch/arm/mach-mediatek/Makefile   |  1 +
 arch/arm/mach-mediatek/mediatek.c | 32 +++++++++++++
 6 files changed, 136 insertions(+)
 create mode 100644 arch/arm/boot/dts/mt6589.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
arch/arm/Kconfig +2 -0
index db3c541..0fc8acd 100644
@@ -997,6 +997,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"
arch/arm/Makefile +1 -0
index 41c1931..8ce9774 100644
@@ -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
arch/arm/boot/dts/mt6589.dtsi new file +94 -0

94 lines not on this page · raw message

arch/arm/mach-mediatek/Kconfig new file +6 -0
new file mode 100644
index 0000000..2c043a2
@@ -0,0 +1,6 @@
+config ARCH_MEDIATEK
+	bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
+	select ARM_GIC
+	select MTK_TIMER
+	help
+	  Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
arch/arm/mach-mediatek/Makefile new file +1 -0
new file mode 100644
index 0000000..43e619f
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
arch/arm/mach-mediatek/mediatek.c new file +32 -0
new file mode 100644
index 0000000..73dfb05
@@ -0,0 +1,32 @@
+/*
+ * Device Tree support for Mediatek SoCs
+ *
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Matthias Brugger <[email protected]>
+ *
+ * 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>
+
+static const char * const mediatek_board_dt_compat[] = {
+	"mediatek,mt6589",
+	NULL,
+};
+
+DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
+	.dt_compat	= mediatek_board_dt_compat,
+MACHINE_END
Signature · 1 line
1.8.1.2
author maintainer
#11 lore raw

PATCH v4 5/6 dt-bindings: add documentation for Mediatek SoC

In reply to Matthias Brugger

This adds a DT binding documentation for the MT6589 SoC from Mediatek.

---
 Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt
Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt new file +8 -0
new file mode 100644
index 0000000..d6ac71f
@@ -0,0 +1,8 @@
+Mediatek MT6589 Platforms Device Tree Bindings
+
+Boards with a SoC of the Mediatek MT6589 shall have the following property:
+
+Required root node property:
+
+compatible: must contain "mediatek,mt6589"
+
Signature · 1 line
1.8.1.2
author maintainer
#12 lore raw

PATCH v4 6/6 arm: mediatek: add dts for Aquaris5 mobile phone

In reply to Matthias Brugger

The Aquaris5 is a mobile phone based on the MT6589 SoC.

---
 arch/arm/boot/dts/mt6589-aquaris5.dts | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 arch/arm/boot/dts/mt6589-aquaris5.dts
arch/arm/boot/dts/mt6589-aquaris5.dts new file +25 -0
new file mode 100644
index 0000000..443b446
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Matthias Brugger <[email protected]>
+ *
+ * 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.
+ */
+
+/dts-v1/;
+#include "mt6589.dtsi"
+
+/ {
+	model = "bq Aquaris5";
+
+	memory {
+		reg = <0x80000000 0x40000000>;
+	};
+};
Signature · 1 line
1.8.1.2
#2 lore raw

Re: [PATCH v4 1/6] clocksource: Add support for the Mediatek SoCs

In reply to Matthias Brugger

Hi Matthias,

just a few suggestions below. Nothing serious.

Quoted 9 lines · Matthias Brugger

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

It is pretty common, I think, to use the free running counter also as sched_clock. You probably want to look into this, but that's just a possible enhancement.

[...]

drivers/clocksource/mtk_timer.c line 193

Quoted 12 lines
drivers/clocksource/mtk_timer.c new file +12 -0
+static void __init mtk_timer_init(struct device_node *node)
+{
+	struct mtk_clock_event_device *evt;
+	struct resource res;
+	unsigned long rate = 0;
+	struct clk *clk;
+	int ret;
+	u32 val;
+
+	evt = kzalloc(sizeof(*evt), GFP_KERNEL);
+	if (!evt)
+		panic("Can't allocate mtk clock event driver struct");

I'm not that sure about the A7s, but on Cortex-A9 there is also a global timer which can be used for timing. And there might be other timing options for this SOC too. Do you really want to panic?

S?ren

#6 lore raw

Re: [PATCH v4 2/6] dt-bindings: add mtk-timer bindings

In reply to Matthias Brugger

Hi Matthias,

Quoted 15 lines · Matthias Brugger

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

---
 .../devicetree/bindings/timer/mediatek,mtk-timer.txt   | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +0 -0
new file mode 100644
index 0000000..938adf6

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt line 5

Quoted 5 lines
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +5 -0
@@ -0,0 +1,18 @@
+Mediatek MT6589, MT6577 and MT6572 Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "mediatek,mtk6589-timer"

Don't you want compatible strings for the other supported SOCs too?

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt line 8

Quoted 3 lines
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +3 -0
+- reg: Should contain location and length for timers register.
+- clocks: Clocks driving the timer hardware. This list shoud include two
+	clocks. The order is system clock and as second clock the RTC clock.

Sorry for being pedantic, but we had so many ugly bindings in our vendor tree. I'm still getting caught up on the clocks. I have the feeling the SOC has two clocks (system and rtc) which are used to drive this timer, while the timer probably refers differently to its clock inputs. If this was the case, the names 'rtc' and 'system' clock are SOC specific names/implementation details. From the timer perspective it is probably just important that it receives two clock inputs. Since the timer is described here and not the SOC, these SOC specific names should disappear and be replaced with the names the timer IP uses for its input clocks.

The clock-names should be listed too, probably as optional properties.

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt line 17

Quoted 9 lines
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +9 -0
+
+Examples:
+
+	timer {
+		compatible = "mediatek,mtk6589-timer";
+		reg = <0x10008000 0x80>;
+		interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&system_clk>, <&rtc_clk>;
+		clock-names = "system-clk", "rtc-clk";

S?ren

author maintainer
#3 lore raw

Re: [PATCH v4 1/6] clocksource: Add support for the Mediatek SoCs

In reply to Sören Brinkmann

El dia 14/05/2014 19:31, "Sören Brinkmann" <[email protected]> va escriure:

Quoted 12 lines

Hi Matthias,

just a few suggestions below. Nothing serious.

Quoted 6 lines · Matthias Brugger

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.

Quoted 7 lines
Quoted 3 lines

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

It is pretty common, I think, to use the free running counter also as sched_clock. You probably want to look into this, but that's just a possible enhancement.

The timer block has also a 64 bit timer. I plan to have a look on this one to use it as sched_clock.

But for now my priority is to get the serial console driver done.

Quoted 18 lines

[...]

drivers/clocksource/mtk_timer.c line 193

Quoted 12 lines
drivers/clocksource/mtk_timer.c new file +12 -0
+static void __init mtk_timer_init(struct device_node *node)
+{
+     struct mtk_clock_event_device *evt;
+     struct resource res;
+     unsigned long rate = 0;
+     struct clk *clk;
+     int ret;
+     u32 val;
+
+     evt = kzalloc(sizeof(*evt), GFP_KERNEL);
+     if (!evt)
+             panic("Can't allocate mtk clock event driver struct");

I'm not that sure about the A7s, but on Cortex-A9 there is also a global timer which can be used for timing. And there might be other timing options for this SOC too. Do you really want to panic?

Yes A7 has a arm local timer, but the problem is, that it is not working with the SoC. It seems like a chip design error as I tried for quite a time to get it working.

Thanks for your comments anyway.

Quoted 2 lines

Sören

author maintainer
#7 lore raw

Re: [PATCH v4 2/6] dt-bindings: add mtk-timer bindings

In reply to Sören Brinkmann

El dia 14/05/2014 19:46, "Sören Brinkmann" <[email protected]> va escriure:

Quoted 10 lines

Hi Matthias,

Quoted 6 lines · Matthias Brugger

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

---
 .../devicetree/bindings/timer/mediatek,mtk-timer.txt   | 18

++++++++++++++++++

Quoted 2 lines
Quoted 2 lines
 1 file changed, 18 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt

Quoted 2 lines
Quoted 2 lines

diff --git

a/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt

Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 0000000..938adf6

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +0 -0
Quoted 9 lines

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt line 5

Quoted 6 lines
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +5 -0
@@ -0,0 +1,18 @@
+Mediatek MT6589, MT6577 and MT6572 Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "mediatek,mtk6589-timer"

Don't you want compatible strings for the other supported SOCs too?

I'm not sure if it makes sense to define the compatible strings for all the SoCs that have this timer as it's actually totally the same IP.

In other cases e.g. the arm gic, not all compatible strings are defined, that's why I use cortex-a15-gic in the dtsi although I'm using a cortex A7 SoC.

I would instead say, that the SoC version of the compatible string, mt6589, is something arbitrary. So I propose to use the first known SoC which uses the timer. That would be AFAIK mt6577.

Quoted 2 lines

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt line 7

Quoted 2 lines
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +2 -0
+- reg: Should contain location and length for timers register.
+- clocks: Clocks driving the timer hardware. This list shoud include

two

Quoted 1 line

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt line 8

Quoted 1 line
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +1 -0
+     clocks. The order is system clock and as second clock the RTC

clock.

Quoted 3 lines

Sorry for being pedantic, but we had so many ugly bindings in our vendor tree. I'm still getting caught up on the clocks. I have the feeling the

SOC

Quoted 8 lines

has two clocks (system and rtc) which are used to drive this timer, while the timer probably refers differently to its clock inputs. If this was the case, the names 'rtc' and 'system' clock are SOC specific names/implementation details. From the timer perspective it is probably just important that it receives two clock inputs. Since the timer is described here and not the SOC, these SOC specific names should disappear and be replaced with the names the timer IP uses for its input clocks.

The timer is exactly identically described in the three SoC datasheets. In the description the clocks are called system and RTC, so I think we are on the safe side here. :)

Quoted 2 lines

The clock-names should be listed too, probably as optional properties.

This will lead to a problem, as the clock-names description includes the order of the clocks. If we make this property optional, it can be easily missunderstood. So I propose to do it the way other drivers in the kernel (e.g. arm,sp804) do it and leave the clock-names property as it is.

Quoted 13 lines

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt line 17

Quoted 10 lines
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +9 -0
+
+Examples:
+
+     timer {
+             compatible = "mediatek,mtk6589-timer";
+             reg = <0x10008000 0x80>;
+             interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
+             clocks = <&system_clk>, <&rtc_clk>;
+             clock-names = "system-clk", "rtc-clk";

Sören

author maintainer
#4 lore raw

PATCH v4 1/6 clocksource: Add support for the Mediatek SoCs

In reply to Sören Brinkmann

Hi all,

I did not realize that Android gmail app sends HTML mails. So I send the comments below accidentally as HTML mail yesterday. Sorry for that.

2014-05-14 18:29 GMT+01:00 S?ren Brinkmann <[email protected]>:

Quoted 11 lines

Hi Matthias,

just a few suggestions below. Nothing serious.

Quoted 6 lines · Matthias Brugger

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.

Quoted 7 lines
Quoted 3 lines

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

It is pretty common, I think, to use the free running counter also as sched_clock. You probably want to look into this, but that's just a possible enhancement.

The timer block has also a 64 bit timer. I plan to have a look on this one to use it as sched_clock.

But for now my priority is to get the serial console driver done.

Quoted 18 lines

[...]

drivers/clocksource/mtk_timer.c line 193

Quoted 12 lines
drivers/clocksource/mtk_timer.c new file +12 -0
+static void __init mtk_timer_init(struct device_node *node)
+{
+     struct mtk_clock_event_device *evt;
+     struct resource res;
+     unsigned long rate = 0;
+     struct clk *clk;
+     int ret;
+     u32 val;
+
+     evt = kzalloc(sizeof(*evt), GFP_KERNEL);
+     if (!evt)
+             panic("Can't allocate mtk clock event driver struct");

I'm not that sure about the A7s, but on Cortex-A9 there is also a global timer which can be used for timing. And there might be other timing options for this SOC too. Do you really want to panic?

Yes, A7 has a arm local timer, but the problem is, that it is not working with the SoC. It seems like a chip design error as I tried for quite a time to get it working.

Thanks for your comments anyway.

Quoted 2 lines

S?ren

Signature · 1 line
motzblog.wordpress.com
author maintainer
#8 lore raw

PATCH v4 2/6 dt-bindings: add mtk-timer bindings

In reply to Sören Brinkmann

Hi all,

I did not realize that Android gmail app sends HTML mails. So I send the comments below accidentally as HTML mail yesterday. Sorry for that.

2014-05-14 18:44 GMT+01:00 S?ren Brinkmann <[email protected]>:

Quoted 12 lines

Hi Matthias,

Quoted 9 lines · Matthias Brugger

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

---
 .../devicetree/bindings/timer/mediatek,mtk-timer.txt   | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
Quoted 13 lines

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt line 5

Quoted 11 lines
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +5 -0
new file mode 100644
index 0000000..938adf6
@@ -0,0 +1,18 @@
+Mediatek MT6589, MT6577 and MT6572 Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "mediatek,mtk6589-timer"

Don't you want compatible strings for the other supported SOCs too?

I'm not sure if it makes sense to define the compatible strings for all the SoCs that have this timer as it's actually totally the same IP.

In other cases e.g. the arm gic, not all compatible strings are defined, that's why I use cortex-a15-gic in the dtsi although I'm using a cortex A7 SoC.

I would instead say, that the SoC version of the compatible string, mt6589, is something arbitrary. So I propose to use the first known SoC which uses the timer. That would be AFAIK mt6577.

Quoted 5 lines

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt line 8

Quoted 4 lines
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +3 -0
+- reg: Should contain location and length for timers register.
+- clocks: Clocks driving the timer hardware. This list shoud include two
+     clocks. The order is system clock and as second clock the RTC clock.
Quoted 10 lines

Sorry for being pedantic, but we had so many ugly bindings in our vendor tree. I'm still getting caught up on the clocks. I have the feeling the SOC has two clocks (system and rtc) which are used to drive this timer, while the timer probably refers differently to its clock inputs. If this was the case, the names 'rtc' and 'system' clock are SOC specific names/implementation details. From the timer perspective it is probably just important that it receives two clock inputs. Since the timer is described here and not the SOC, these SOC specific names should disappear and be replaced with the names the timer IP uses for its input clocks.

The timer is exactly identically described in the three SoC datasheets. In the description the clocks are called system and RTC, so I think we are on the safe side here. :)

Quoted 2 lines

The clock-names should be listed too, probably as optional properties.

This will lead to a problem, as the clock-names description includes the order of the clocks. If we make this property optional, it can be easily missunderstood. So I propose to do it the way other drivers in the kernel (e.g. arm,sp804) do it and leave the clock-names property as it is.

Quoted 13 lines

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt line 17

Quoted 10 lines
Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt new file +9 -0
+
+Examples:
+
+     timer {
+             compatible = "mediatek,mtk6589-timer";
+             reg = <0x10008000 0x80>;
+             interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
+             clocks = <&system_clk>, <&rtc_clk>;
+             clock-names = "system-clk", "rtc-clk";

S?ren

Signature · 1 line
motzblog.wordpress.com