* [PATCH v2 0/4] arm: Add basic support for Mediatek Cortex-A7 SoCs
@ 2014-05-11 1:40 Matthias Brugger
2014-05-11 1:41 ` [PATCH v2 1/4] clocksource: Add support for the Mediatek SoCs Matthias Brugger
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Matthias Brugger @ 2014-05-11 1:40 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, sboyd,
gregory.clement, arnd, robherring2, marc.zyngier, maxime.ripard,
devicetree, linux-doc, linux-arm-kernel
Second round for the basic support of the mt6589 SoC from Mediatek.
I droped the patch which introduced low-level-debug for the Soc, because of
the missing serial device driver. This would prohibit the use of a multi-
platform kernel with this series. I will re-submit the patch for low-level-
debugging, when the serial driver got committed.
I added support for the Aquaris5 mobile phone, although at the moment you can't
really do anything with the phone. I also renamed the mtk6589.dtsi to
mt6589.dtsi as it better reflects the SoC name given by Mediatek.
---
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.
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
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 (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 dts for Aquaris5 mobile phone
.../devicetree/bindings/arm/mediatek-mt65xx.txt | 8 +
.../bindings/timer/mediatek,mtk-timer.txt | 17 ++
.../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 | 93 ++++++++
arch/arm/mach-mediatek/Kconfig | 6 +
arch/arm/mach-mediatek/Makefile | 1 +
arch/arm/mach-mediatek/mediatek.c | 38 ++++
drivers/clocksource/Kconfig | 4 +
drivers/clocksource/Makefile | 1 +
drivers/clocksource/mtk_timer.c | 240 +++++++++++++++++++++
13 files changed, 437 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
--
1.8.1.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/4] clocksource: Add support for the Mediatek SoCs
2014-05-11 1:40 [PATCH v2 0/4] arm: Add basic support for Mediatek Cortex-A7 SoCs Matthias Brugger
@ 2014-05-11 1:41 ` Matthias Brugger
2014-05-11 4:45 ` Maxime Ripard
[not found] ` <1399772463-859-2-git-send-email-matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-11 1:41 ` [PATCH v2 2/4] dt-bindings: add mtk-timer bindings Matthias Brugger
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Matthias Brugger @ 2014-05-11 1:41 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, sboyd,
gregory.clement, arnd, robherring2, marc.zyngier, maxime.ripard,
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 | 240 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 245 insertions(+)
create mode 100644 drivers/clocksource/mtk_timer.c
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 96918e1..1f73740 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
+ select CLKSRC_MMIO
+ 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..796b888
--- /dev/null
+++ b/drivers/clocksource/mtk_timer.c
@@ -0,0 +1,240 @@
+/*
+ * 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/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,
+ .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 = 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 void __init mtk_timer_init(struct device_node *node)
+{
+ struct resource res;
+ unsigned long rate = 0;
+ struct clk *clk;
+ int ret, irq;
+ u32 val;
+
+ if (of_address_to_resource(node, 0, &res))
+ panic("Failed to parse resource\n");
+
+ if (!request_mem_region(res.start, resource_size(&res), "mtk-timer"))
+ panic("Registers are a busy IO resource");
+
+ gpt_base = ioremap(res.start, resource_size(&res));
+ 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(node, 0);
+ 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 = request_irq(irq, mtk_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL,
+ "mtk_timer", &mtk_clockevent);
+ 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);
+
+ clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
+ 0xffffffff);
+}
+CLOCKSOURCE_OF_DECLARE(mtk_mt6589, "mediatek,mtk6589-timer", mtk_timer_init);
+
--
1.8.1.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/4] dt-bindings: add mtk-timer bindings
2014-05-11 1:40 [PATCH v2 0/4] arm: Add basic support for Mediatek Cortex-A7 SoCs Matthias Brugger
2014-05-11 1:41 ` [PATCH v2 1/4] clocksource: Add support for the Mediatek SoCs Matthias Brugger
@ 2014-05-11 1:41 ` Matthias Brugger
2014-05-11 4:49 ` Maxime Ripard
2014-05-11 1:41 ` [PATCH v2 3/4] arm: add basic support for Mediatek MT6589 boards Matthias Brugger
2014-05-11 1:41 ` [PATCH v2 4/4] arm: mediatek: add dts for Aquaris5 mobile phone Matthias Brugger
3 siblings, 1 reply; 10+ messages in thread
From: Matthias Brugger @ 2014-05-11 1:41 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, sboyd,
gregory.clement, arnd, robherring2, marc.zyngier, maxime.ripard,
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>
---
.../devicetree/bindings/timer/mediatek,mtk-timer.txt | 17 +++++++++++++++++
1 file changed, 17 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..a36eb0f
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
@@ -0,0 +1,17 @@
+Mediatek MT6598, MT6577 and MT6572 Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "mediatek,mtk6589-timer"
+- reg: Should contain location and length for timers register.
+- clocks : phandle to the clock source, normaly a 13 MHz fixed system clock
+ and a 32 KHz fixed RTC clock.
+
+Examples:
+
+ timer {
+ compatible = "mediatek,mtk6589-timer";
+ reg = <0x10008000 0x80>;
+ interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>;
+ clocks = <&system_clk>, <&rtc_clk>;
+ };
--
1.8.1.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/4] arm: add basic support for Mediatek MT6589 boards
2014-05-11 1:40 [PATCH v2 0/4] arm: Add basic support for Mediatek Cortex-A7 SoCs Matthias Brugger
2014-05-11 1:41 ` [PATCH v2 1/4] clocksource: Add support for the Mediatek SoCs Matthias Brugger
2014-05-11 1:41 ` [PATCH v2 2/4] dt-bindings: add mtk-timer bindings Matthias Brugger
@ 2014-05-11 1:41 ` Matthias Brugger
2014-05-11 4:56 ` Maxime Ripard
2014-05-12 9:30 ` Arnd Bergmann
2014-05-11 1:41 ` [PATCH v2 4/4] arm: mediatek: add dts for Aquaris5 mobile phone Matthias Brugger
3 siblings, 2 replies; 10+ messages in thread
From: Matthias Brugger @ 2014-05-11 1:41 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, sboyd,
gregory.clement, arnd, robherring2, marc.zyngier, maxime.ripard,
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/arm/mediatek-mt65xx.txt | 8 ++
.../devicetree/bindings/vendor-prefixes.txt | 1 +
arch/arm/Kconfig | 2 +
arch/arm/Makefile | 1 +
arch/arm/boot/dts/mt6589.dtsi | 93 ++++++++++++++++++++++
arch/arm/mach-mediatek/Kconfig | 6 ++
arch/arm/mach-mediatek/Makefile | 1 +
arch/arm/mach-mediatek/mediatek.c | 38 +++++++++
8 files changed, 150 insertions(+)
create mode 100644 Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt
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
diff --git a/Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt b/Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt
new file mode 100644
index 0000000..d6ac71f
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt
@@ -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"
+
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index abc3080..73f9e4c 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -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
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index db3c541..0fc8acd 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -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"
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/mt6589.dtsi b/arch/arm/boot/dts/mt6589.dtsi
new file mode 100644
index 0000000..2af140d
--- /dev/null
+++ b/arch/arm/boot/dts/mt6589.dtsi
@@ -0,0 +1,93 @@
+/*
+ * 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";
+ reg = <0x0>;
+ };
+ cpu@1 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a7";
+ reg = <0x1>;
+ };
+ cpu@2 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a7";
+ reg = <0x2>;
+ };
+ cpu@3 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a7";
+ reg = <0x3>;
+ };
+
+ };
+
+ clocks {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+
+ dummy13m: dummy13m {
+ compatible = "fixed-clock";
+ clock-frequency = <13000000>;
+ #clock-cells = <0>;
+ };
+
+ dummy32k: dummy32k {
+ compatible = "fixed-clock";
+ clock-frequency = <32000>;
+ #clock-cells = <0>;
+ };
+ };
+
+ 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>,
+ <0x10214000 0x2000>,
+ <0x10216000 0x2000>;
+ };
+
+ timer: timer@10008000 {
+ compatible = "mediatek,mtk6589-timer";
+ reg = <0x10008000 0x80>;
+ interrupts = <GIC_SPI 113 IRQ_TYPE_EDGE_RISING>;
+ clocks = <&dummy13m>, <&dummy32k>;
+ };
+ };
+};
diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
new file mode 100644
index 0000000..2c043a2
--- /dev/null
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -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.
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..0487fc7
--- /dev/null
+++ b/arch/arm/mach-mediatek/mediatek.c
@@ -0,0 +1,38 @@
+/*
+ * 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>
+
+static void __init mediatek_dt_init(void)
+{
+ 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.8.1.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 4/4] arm: mediatek: add dts for Aquaris5 mobile phone
2014-05-11 1:40 [PATCH v2 0/4] arm: Add basic support for Mediatek Cortex-A7 SoCs Matthias Brugger
` (2 preceding siblings ...)
2014-05-11 1:41 ` [PATCH v2 3/4] arm: add basic support for Mediatek MT6589 boards Matthias Brugger
@ 2014-05-11 1:41 ` Matthias Brugger
3 siblings, 0 replies; 10+ messages in thread
From: Matthias Brugger @ 2014-05-11 1:41 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, sboyd,
gregory.clement, arnd, robherring2, marc.zyngier, maxime.ripard,
devicetree, linux-doc, linux-arm-kernel
The Aquaris5 is a mobile phone based on the mt6589 SoC.
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
arch/arm/boot/dts/mt6589-aquaris5.dts | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 arch/arm/boot/dts/mt6589-aquaris5.dts
diff --git a/arch/arm/boot/dts/mt6589-aquaris5.dts b/arch/arm/boot/dts/mt6589-aquaris5.dts
new file mode 100644
index 0000000..443b446
--- /dev/null
+++ b/arch/arm/boot/dts/mt6589-aquaris5.dts
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/dts-v1/;
+#include "mt6589.dtsi"
+
+/ {
+ model = "bq Aquaris5";
+
+ memory {
+ reg = <0x80000000 0x40000000>;
+ };
+};
--
1.8.1.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/4] clocksource: Add support for the Mediatek SoCs
2014-05-11 1:41 ` [PATCH v2 1/4] clocksource: Add support for the Mediatek SoCs Matthias Brugger
@ 2014-05-11 4:45 ` Maxime Ripard
[not found] ` <1399772463-859-2-git-send-email-matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
1 sibling, 0 replies; 10+ messages in thread
From: Maxime Ripard @ 2014-05-11 4:45 UTC (permalink / raw)
To: Matthias Brugger
Cc: linux-kernel, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
galak, rdunlap, linux, daniel.lezcano, tglx, thierry.reding,
florian.vaussard, jic23, jason, andrew, silvio.fricke,
heiko.stuebner, olof, sebastian.hesselbarth, sboyd,
gregory.clement, arnd, robherring2, marc.zyngier, devicetree,
linux-doc, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 9699 bytes --]
On Sun, May 11, 2014 at 03:41:00AM +0200, 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 | 240 ++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 245 insertions(+)
> create mode 100644 drivers/clocksource/mtk_timer.c
>
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 96918e1..1f73740 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
> + select CLKSRC_MMIO
> + 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..796b888
> --- /dev/null
> +++ b/drivers/clocksource/mtk_timer.c
> @@ -0,0 +1,240 @@
> +/*
> + * 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/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,
> + .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 = 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 void __init mtk_timer_init(struct device_node *node)
> +{
> + struct resource res;
> + unsigned long rate = 0;
> + struct clk *clk;
> + int ret, irq;
> + u32 val;
> +
> + if (of_address_to_resource(node, 0, &res))
> + panic("Failed to parse resource\n");
> +
> + if (!request_mem_region(res.start, resource_size(&res), "mtk-timer"))
> + panic("Registers are a busy IO resource");
> +
> + gpt_base = ioremap(res.start, resource_size(&res));
> + 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(node, 0);
> + 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 = request_irq(irq, mtk_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL,
> + "mtk_timer", &mtk_clockevent);
> + 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);
> +
> + clockevents_config_and_register(&mtk_clockevent, rate, 0x3,
> + 0xffffffff);
You should also set the cpumask and irq fields in mtk_clockevent.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/4] dt-bindings: add mtk-timer bindings
2014-05-11 1:41 ` [PATCH v2 2/4] dt-bindings: add mtk-timer bindings Matthias Brugger
@ 2014-05-11 4:49 ` Maxime Ripard
0 siblings, 0 replies; 10+ messages in thread
From: Maxime Ripard @ 2014-05-11 4:49 UTC (permalink / raw)
To: Matthias Brugger
Cc: linux-kernel, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
galak, rdunlap, linux, daniel.lezcano, tglx, thierry.reding,
florian.vaussard, jic23, jason, andrew, silvio.fricke,
heiko.stuebner, olof, sebastian.hesselbarth, sboyd,
gregory.clement, arnd, robherring2, marc.zyngier, devicetree,
linux-doc, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]
On Sun, May 11, 2014 at 03:41:01AM +0200, 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>
> ---
> .../devicetree/bindings/timer/mediatek,mtk-timer.txt | 17 +++++++++++++++++
> 1 file changed, 17 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..a36eb0f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt
> @@ -0,0 +1,17 @@
> +Mediatek MT6598, MT6577 and MT6572 Timers
> +---------------------------------------
> +
> +Required properties:
> +- compatible: Should be "mediatek,mtk6589-timer"
> +- reg: Should contain location and length for timers register.
> +- clocks : phandle to the clock source, normaly a 13 MHz fixed system clock
> + and a 32 KHz fixed RTC clock.
If you don't want to use clock names for this, you should put the
order that you require them to be.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 3/4] arm: add basic support for Mediatek MT6589 boards
2014-05-11 1:41 ` [PATCH v2 3/4] arm: add basic support for Mediatek MT6589 boards Matthias Brugger
@ 2014-05-11 4:56 ` Maxime Ripard
2014-05-12 9:30 ` Arnd Bergmann
1 sibling, 0 replies; 10+ messages in thread
From: Maxime Ripard @ 2014-05-11 4:56 UTC (permalink / raw)
To: Matthias Brugger
Cc: linux-kernel, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
galak, rdunlap, linux, daniel.lezcano, tglx, thierry.reding,
florian.vaussard, jic23, jason, andrew, silvio.fricke,
heiko.stuebner, olof, sebastian.hesselbarth, sboyd,
gregory.clement, arnd, robherring2, marc.zyngier, devicetree,
linux-doc, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 8204 bytes --]
Hi,
On Sun, May 11, 2014 at 03:41:02AM +0200, 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/arm/mediatek-mt65xx.txt | 8 ++
> .../devicetree/bindings/vendor-prefixes.txt | 1 +
> arch/arm/Kconfig | 2 +
> arch/arm/Makefile | 1 +
> arch/arm/boot/dts/mt6589.dtsi | 93 ++++++++++++++++++++++
> arch/arm/mach-mediatek/Kconfig | 6 ++
> arch/arm/mach-mediatek/Makefile | 1 +
> arch/arm/mach-mediatek/mediatek.c | 38 +++++++++
> 8 files changed, 150 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt
> 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
This probably should belong into different patches.
Something like:
- one to document the prefix
- one to add mach-mediatek
- one to add the DTSI
>
> diff --git a/Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt b/Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt
> new file mode 100644
> index 0000000..d6ac71f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/mediatek-mt65xx.txt
> @@ -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"
> +
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index abc3080..73f9e4c 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -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
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index db3c541..0fc8acd 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -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"
> 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/mt6589.dtsi b/arch/arm/boot/dts/mt6589.dtsi
> new file mode 100644
> index 0000000..2af140d
> --- /dev/null
> +++ b/arch/arm/boot/dts/mt6589.dtsi
> @@ -0,0 +1,93 @@
> +/*
> + * 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";
> + reg = <0x0>;
> + };
> + cpu@1 {
> + device_type = "cpu";
> + compatible = "arm,cortex-a7";
> + reg = <0x1>;
> + };
> + cpu@2 {
> + device_type = "cpu";
> + compatible = "arm,cortex-a7";
> + reg = <0x2>;
> + };
> + cpu@3 {
> + device_type = "cpu";
> + compatible = "arm,cortex-a7";
> + reg = <0x3>;
> + };
> +
> + };
> +
> + clocks {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + ranges;
> +
> + dummy13m: dummy13m {
> + compatible = "fixed-clock";
> + clock-frequency = <13000000>;
> + #clock-cells = <0>;
> + };
> +
> + dummy32k: dummy32k {
> + compatible = "fixed-clock";
> + clock-frequency = <32000>;
> + #clock-cells = <0>;
> + };
> + };
> +
> + soc {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + compatible = "simple-bus";
> + clock-ranges;
> + ranges;
> +
> + gic: interrupt-controller@10212000 {
> + compatible = "arm,cortex-a9-gic";
cortex-a15-gic would probably be more appropriate?
> + interrupt-controller;
> + #interrupt-cells = <3>;
> + reg = <0x10211000 0x1000>,
> + <0x10212000 0x1000>,
> + <0x10214000 0x2000>,
> + <0x10216000 0x2000>;
> + };
> +
> + timer: timer@10008000 {
> + compatible = "mediatek,mtk6589-timer";
> + reg = <0x10008000 0x80>;
> + interrupts = <GIC_SPI 113 IRQ_TYPE_EDGE_RISING>;
> + clocks = <&dummy13m>, <&dummy32k>;
> + };
Usually, we try to order the nodes by physical addresses in the DT.
> + };
> +};
> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> new file mode 100644
> index 0000000..2c043a2
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/Kconfig
> @@ -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.
> 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..0487fc7
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/mediatek.c
> @@ -0,0 +1,38 @@
> +/*
> + * 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>
> +
> +static void __init mediatek_dt_init(void)
> +{
> + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +}
This is the default, you can remove it.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 3/4] arm: add basic support for Mediatek MT6589 boards
2014-05-11 1:41 ` [PATCH v2 3/4] arm: add basic support for Mediatek MT6589 boards Matthias Brugger
2014-05-11 4:56 ` Maxime Ripard
@ 2014-05-12 9:30 ` Arnd Bergmann
1 sibling, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2014-05-12 9:30 UTC (permalink / raw)
To: Matthias Brugger
Cc: linux-kernel, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
galak, rdunlap, linux, daniel.lezcano, tglx, thierry.reding,
florian.vaussard, jic23, jason, andrew, silvio.fricke,
heiko.stuebner, olof, sebastian.hesselbarth, sboyd,
gregory.clement, robherring2, marc.zyngier, maxime.ripard,
devicetree, linux-doc, linux-arm-kernel
On Sunday 11 May 2014 03:41:02 Matthias Brugger wrote:
> +
> +static void __init mediatek_dt_init(void)
> +{
> + 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
Since the mediatek_dt_init function now only does the default populate
call, you can leave it out completely and keep only the compat list.
Arnd
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/4] clocksource: Add support for the Mediatek SoCs
[not found] ` <1399772463-859-2-git-send-email-matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2014-05-12 9:37 ` Arnd Bergmann
0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2014-05-12 9:37 UTC (permalink / raw)
To: Matthias Brugger
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
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,
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,
sboyd-sgV2jX0FEOL9JmXXK+q4OQ,
gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
robherring2-Re5JQEeQqe8AvxtiuMwx3w, marc.zyngier-5wv7dgnIgG8,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Sunday 11 May 2014 03:41:00 Matthias Brugger wrote:
> +
> +static void __iomem *gpt_base;
> +static u32 ticks_per_jiffy;
> +
This is not wrong, because there will only be one timer, but the
preferred way to express this in general would be to add it to the
clock_event_device pointer:
struct mtk_clock_event_device {
void __iomem *gpt_base;
u32 ticks_per_jiffy;
struct clock_event_device dev;
};
static inline struct mtk_clock_event_device *to_mtk_clock(struct clock_event_device *c)
{
return container_of(c, struct mtk_clock_event_device, dev);
}
static irqreturn_t mtk_timer_interrupt(int irq, void *dev_id)
{
struct mtk_clock_event_device *evt = dev_id;
/* Acknowledge timer0 irq */
writel(GPT_IRQ_ACK(GPT_CLK_EVT), evt->gpt_base + GPT_IRQ_ACK_REG);
evt->dev.event_handler(evt);
return IRQ_HANDLED;
}
static void mtk_clkevt_mode(enum clock_event_mode mode,
struct clock_event_device *clk)
{
struct mtk_clock_event_device *evt = to_mtk_clock(clk);
mtk_clkevt_time_stop(GPT_CLK_EVT);
switch (mode) {
case CLOCK_EVT_MODE_PERIODIC:
mtk_clkevt_time_setup(evt->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;
}
}
Arnd
--
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] 10+ messages in thread
end of thread, other threads:[~2014-05-12 9:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-11 1:40 [PATCH v2 0/4] arm: Add basic support for Mediatek Cortex-A7 SoCs Matthias Brugger
2014-05-11 1:41 ` [PATCH v2 1/4] clocksource: Add support for the Mediatek SoCs Matthias Brugger
2014-05-11 4:45 ` Maxime Ripard
[not found] ` <1399772463-859-2-git-send-email-matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-12 9:37 ` Arnd Bergmann
2014-05-11 1:41 ` [PATCH v2 2/4] dt-bindings: add mtk-timer bindings Matthias Brugger
2014-05-11 4:49 ` Maxime Ripard
2014-05-11 1:41 ` [PATCH v2 3/4] arm: add basic support for Mediatek MT6589 boards Matthias Brugger
2014-05-11 4:56 ` Maxime Ripard
2014-05-12 9:30 ` Arnd Bergmann
2014-05-11 1:41 ` [PATCH v2 4/4] arm: mediatek: add dts for Aquaris5 mobile phone Matthias Brugger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).