arm: mediatek: Add more basic features
Subsystems (5)
Matthias Brugger
maintainerv2 cover arm: mediatek: Add more basic features
This patch set adds some minor changes to the Mediatek mt6589 support.
The most important patch enables the arm arch timer for mt6589. As already seen on other vendor SoCs, to enable the arch timer we have to enable a SoC timer. This should be normally done by the bootloader. As up to now no open source bootloader exists for the mt6589, I added the functionality to the init_time function.
Other features are low-level debugging on the mt6589, the addition to the "make dtbs" and multi_v7_defconfig, as well as a small typo in the dtsi file.
The patch set is based on v3.17-rc1
Changes for v2:
- rebased on v3.17-rc1
- add patch for the compatible property of aquaris5
- add patch setting GIC compatible string to new "arm,cortex-a7-gic"
- set ARM arch timer frequency in DTS
---
Matthias Brugger (9):
arm: dts: Build dtb for Mediatek board
arm: multi_v7_defconfig: Enable Mediatek platform
arm: dts: mt6589: Fix typo in GIC unit address
arm: mediatek: Add earlyprintk support for mt6589
arm: dts: mt6589-aquaris5: Add boot argument earlyprintk
arm: mediatek: enable gpt6 on boot up to make arch timer working
arm: dts: mt6589: Add arm arch timer node
arm: dts: mediatek: Add compatible property for aquaris5
arm: dts: mt6589: Change compatible string for GIC
Documentation/devicetree/bindings/arm/mediatek.txt | 6 +++++ arch/arm/Kconfig.debug | 10 ++++++++ arch/arm/boot/dts/Makefile | 1 + arch/arm/boot/dts/mt6589-aquaris5.dts | 5 ++++ arch/arm/boot/dts/mt6589.dtsi | 17 ++++++++++--- arch/arm/configs/multi_v7_defconfig | 1 + arch/arm/mach-mediatek/mediatek.c | 26 ++++++++++++++++++++ 7 files changed, 62 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.9.5
Matthias Brugger
maintainerPATCH v2 1/9 arm: dts: Build dtb for Mediatek board
This allows the "make dtbs" to build the aquaris5 dtb for the Mediatek SoC.
--- arch/arm/boot/dts/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/Makefile +1 -0
@@ -491,6 +491,7 @@ dtb-$(CONFIG_MACH_DOVE) += dove-cm-a510.dtb \ dove-d2plug.dtb \ dove-d3plug.dtb \ dove-dove-db.dtb +dtb-$(CONFIG_ARCH_MEDIATEK) += mt6589-aquaris5.dtb targets += dtbs dtbs_install targets += $(dtb-y)
Signature · 1 line
1.7.9.5
Matthias Brugger
maintainerPATCH v2 2/9 arm: multi_v7_defconfig: Enable Mediatek platform
In reply to Matthias BruggerEnable Mediatek platform support for multi_v7_defconfig.
--- arch/arm/configs/multi_v7_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/multi_v7_defconfig +1 -0
@@ -42,6 +42,7 @@ CONFIG_SOC_AM33XX=y CONFIG_SOC_AM43XX=y CONFIG_SOC_DRA7XX=y CONFIG_ARCH_QCOM=y +CONFIG_ARCH_MEDIATEK=y CONFIG_ARCH_MSM8X60=y CONFIG_ARCH_MSM8960=y CONFIG_ARCH_MSM8974=y
Signature · 1 line
1.7.9.5
Matthias Brugger
maintainerPATCH v2 3/9 arm: dts: mt6589: Fix typo in GIC unit address
In reply to Matthias BruggerThis changes the unit address of the gic node to it's first register area.
--- arch/arm/boot/dts/mt6589.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/mt6589.dtsi +1 -1
@@ -81,7 +81,7 @@ clock-names = "system-clk", "rtc-clk"; }; - gic: interrupt-controller at 10212000 { + gic: interrupt-controller at 10211000 { compatible = "arm,cortex-a15-gic"; interrupt-controller; #interrupt-cells = <3>;
Signature · 1 line
1.7.9.5
Matthias Brugger
maintainerPATCH v2 4/9 arm: mediatek: Add earlyprintk support for mt6589
In reply to Matthias BruggerEnable low-level debug for Mediatek mt6589 SoC on UART0.
--- arch/arm/Kconfig.debug | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm/Kconfig.debug +10 -0
@@ -834,6 +834,14 @@ choice Say Y here if you want kernel low-level debugging support on Ux500 based platforms. + config DEBUG_MT6589_UART0 + bool "Mediatek mt6589 UART0" + depends on ARCH_MEDIATEK + select DEBUG_UART_8250 + help + Say Y here if you want kernel low-level debugging support + for Mediatek mt6589 based platforms on UART0. + config DEBUG_VEXPRESS_UART0_DETECT bool "Autodetect UART0 on Versatile Express Cortex-A core tiles" depends on ARCH_VEXPRESS && CPU_CP15_MMU
@@ -1075,6 +1083,7 @@ config DEBUG_UART_PHYS default 0x10126000 if DEBUG_RK3X_UART1 default 0x101f1000 if ARCH_VERSATILE default 0x101fb000 if DEBUG_NOMADIK_UART + default 0x11006000 if DEBUG_MT6589_UART0 default 0x16000000 if ARCH_INTEGRATOR default 0x18000300 if DEBUG_BCM_5301X default 0x1c090000 if DEBUG_VEXPRESS_UART0_RS1
@@ -1137,6 +1146,7 @@ config DEBUG_UART_VIRT default 0xf01fb000 if DEBUG_NOMADIK_UART default 0xf0201000 if DEBUG_BCM2835 default 0xf1000300 if DEBUG_BCM_5301X + default 0xf1006000 if DEBUG_MT6589_UART0 default 0xf11f1000 if ARCH_VERSATILE default 0xf1600000 if ARCH_INTEGRATOR default 0xf1c28000 if DEBUG_SUNXI_UART0
Signature · 1 line
1.7.9.5
Matthias Brugger
maintainerPATCH v2 5/9 arm: dts: mt6589-aquaris5: Add boot argument earlyprintk
In reply to Matthias BruggerAdd boot argument for earlyprintk to the aquaris5 device tree file.
--- arch/arm/boot/dts/mt6589-aquaris5.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/mt6589-aquaris5.dts +4 -0
@@ -19,6 +19,10 @@ / { model = "bq Aquaris5"; + chosen { + bootargs = "earlyprintk"; + }; + memory { reg = <0x80000000 0x40000000>; };
Signature · 1 line
1.7.9.5
Matthias Brugger
maintainerPATCH v2 6/9 arm: mediatek: enable gpt6 on boot up to make arch timer working
In reply to Matthias BruggerWe enable GTP6 which ungates the arch timer clock. Apart we write the frequency with which the timer is running in the CNTFREQ register. In the future this should be done in the bootloader.
--- arch/arm/mach-mediatek/mediatek.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
arch/arm/mach-mediatek/mediatek.c +26 -0
@@ -16,6 +16,31 @@*/ #include <linux/init.h> #include <asm/mach/arch.h> +#include <linux/of.h> +#include <linux/clk-provider.h> +#include <linux/clocksource.h> + +#define TIMER_CTRL_OP_FREERUN 0x30 +#define TIMER_CTRL_ENABLE 0x01 + +#define GPT6_CON_MT65xx 0x10008060 + +static void __init mediatek_timer_init (void ) +{ +static void __iomem *gpt_base; + +if (of_machine_is_compatible ("mediatek,mt6589" )) { +/* turn on GPT6 which ungates arch timer clocks */ + gpt_base =ioremap (GPT6_CON_MT65xx,0x04 ); + } + +/* enabel clock and set to free-run */ +if (gpt_base) +writel (TIMER_CTRL_OP_FREERUN |TIMER_CTRL_ENABLE , gpt_base); + +of_clk_init (NULL ); +clocksource_of_init (); +};static const char *const mediatek_board_dt_compat[] = {"mediatek,mt6589" ,
@@ -24,4 +49,5 @@ static const char * const mediatek_board_dt_compat[] = {DT_MACHINE_START (MEDIATEK_DT ,"Mediatek Cortex-A7 (Device Tree)" ) .dt_compat = mediatek_board_dt_compat, + .init_time = mediatek_timer_init,MACHINE_END
Signature · 1 line
1.7.9.5
PATCH v2 6/9 arm: mediatek: enable gpt6 on boot up to make arch timer working
Hi Matthias,
Quoted 2 lines · Matthias Brugger
We enable GTP6 which ungates the arch timer clock. Apart we write the frequency with which the timer is running in the CNTFREQ register.
We don't seem to set CNTFRQ below. Does it happen to have a consistent value on current versions of the bootloader?
Quoted 1 line
In the future this should be done in the bootloader.
Do we know how far in the future that's likely to be?
What's the plan for this code when such a bootloader becomes available?
Thanks,
Mark.
Quoted 51 lines
Signed-off-by Matthias Brugger <[email protected]>--- arch/arm/mach-mediatek/mediatek.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)arch/arm/mach-mediatek/mediatek.c +26
-0@@ -16,6 +16,31 @@*/ #include <linux/init.h> #include <asm/mach/arch.h> +#include <linux/of.h> +#include <linux/clk-provider.h> +#include <linux/clocksource.h> + +#define TIMER_CTRL_OP_FREERUN 0x30 +#define TIMER_CTRL_ENABLE 0x01 + +#define GPT6_CON_MT65xx 0x10008060 + +static void __init mediatek_timer_init (void ) +{ +static void __iomem *gpt_base; + +if (of_machine_is_compatible ("mediatek,mt6589" )) { +/* turn on GPT6 which ungates arch timer clocks */ + gpt_base =ioremap (GPT6_CON_MT65xx,0x04 ); + } + +/* enabel clock and set to free-run */ +if (gpt_base) +writel (TIMER_CTRL_OP_FREERUN |TIMER_CTRL_ENABLE , gpt_base); + +of_clk_init (NULL ); +clocksource_of_init (); +};static const char *const mediatek_board_dt_compat[] = {"mediatek,mt6589" ,@@ -24,4 +49,5 @@ static const char * const mediatek_board_dt_compat[] = {DT_MACHINE_START (MEDIATEK_DT ,"Mediatek Cortex-A7 (Device Tree)" ) .dt_compat = mediatek_board_dt_compat, + .init_time = mediatek_timer_init,MACHINE_END Signature · 1 line
1.7.9.5
Matthias Brugger
maintainerRe: [PATCH v2 6/9] arm: mediatek: enable gpt6 on boot up to make arch timer working
2014-08-18 17:45 GMT+02:00 Mark Rutland <[email protected]>:
Quoted 8 lines
Hi Matthias,
Quoted 2 lines · Matthias Brugger
We enable GTP6 which ungates the arch timer clock. Apart we write the frequency with which the timer is running in the CNTFREQ register.
We don't seem to set CNTFRQ below. Does it happen to have a consistent value on current versions of the bootloader?
Oh sorry, my fault. In v2 I moved the frequency to the dts, as this will make the driver write CNTFRQ.
I forgot to update the commit message.
Quoted 4 lines
Quoted 2 lines
In the future this should be done in the bootloader.
Do we know how far in the future that's likely to be?
AFAIK no one right now is working on an open source bootloader for the mediatek devices.
So I think we won't see an open source bootloader in a reasonable time.
Quoted 2 lines
What's the plan for this code when such a bootloader becomes available?
I think when a bootloader becomes available, this code should be removed. I know that this will lead to a not working ARM arch timer in devices which don't migrate to the new bootloader, but I think it's not too critical. Apart from the ARM arch timer, the devices have the mediatek global porpose timer (drivers/clocksource/mtk_timer.c), which implement a clock source and a clock event timer. So the system won't hang.
Cheers,
Matthias
Quoted 55 lines
Thanks,
Mark.Quoted 51 lines
Signed-off-by Matthias Brugger <[email protected]>--- arch/arm/mach-mediatek/mediatek.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)arch/arm/mach-mediatek/mediatek.c +26
-1@@ -16,6 +16,31 @@*/ #include <linux/init.h> #include <asm/mach/arch.h> +#include <linux/of.h> +#include <linux/clk-provider.h> +#include <linux/clocksource.h> + +#define TIMER_CTRL_OP_FREERUN 0x30 +#define TIMER_CTRL_ENABLE 0x01 + +#define GPT6_CON_MT65xx 0x10008060 + +static void __init mediatek_timer_init (void ) +{ +static void __iomem *gpt_base; + +if (of_machine_is_compatible ("mediatek,mt6589" )) { +/* turn on GPT6 which ungates arch timer clocks */ + gpt_base =ioremap (GPT6_CON_MT65xx,0x04 ); + } + +/* enabel clock and set to free-run */ +if (gpt_base) +writel (TIMER_CTRL_OP_FREERUN |TIMER_CTRL_ENABLE , gpt_base); + +of_clk_init (NULL ); +clocksource_of_init (); +};static const char *const mediatek_board_dt_compat[] = {"mediatek,mt6589" ,@@ -24,4 +49,5 @@ static const char * const mediatek_board_dt_compat[] = {DT_MACHINE_START (MEDIATEK_DT ,"Mediatek Cortex-A7 (Device Tree)" ) .dt_compat = mediatek_board_dt_compat, + .init_time = mediatek_timer_init,MACHINE_END --1.7.9.5
Signature · 1 line
motzblog.wordpress.com
Re: [PATCH v2 6/9] arm: mediatek: enable gpt6 on boot up to make arch timer working
Quoted 7 lines · Matthias Brugger
2014-08-18 17:45 GMT+02:00 Mark Rutland <[email protected]>:
Quoted 6 lines
Hi Matthias,
Quoted 2 lines · Matthias Brugger
We enable GTP6 which ungates the arch timer clock. Apart we write the frequency with which the timer is running in the CNTFREQ register.
Quoted 6 lines
Quoted 2 lines
We don't seem to set CNTFRQ below. Does it happen to have a consistent value on current versions of the bootloader?
Oh sorry, my fault. In v2 I moved the frequency to the dts, as this will make the driver write CNTFRQ.
I forgot to update the commit message.
The arch timer driver does not write CNTFRQ as this can only be done from the secure side. It simply uses the value provided internally. This isn't sufficient for virtualization guests (which need to have CNTFRQ programmed correctly).
For the moment as we're not booting at Hyp that's not necessarily a big problem, but it is a shame.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
In the future this should be done in the bootloader.
Do we know how far in the future that's likely to be?
AFAIK no one right now is working on an open source bootloader for the mediatek devices.
So I think we won't see an open source bootloader in a reasonable time.
Ok. :(
Quoted 9 lines
Quoted 1 line
What's the plan for this code when such a bootloader becomes available?
I think when a bootloader becomes available, this code should be removed. I know that this will lead to a not working ARM arch timer in devices which don't migrate to the new bootloader, but I think it's not too critical. Apart from the ARM arch timer, the devices have the mediatek global porpose timer (
drivers/clocksource/mtk_timer.c), which implement a clock source and a clock event timer. So the system won't hang.
I fear that's never going to happen, either because such a bootloader never becomes available or because there will be hold-outs sticking to the old loader.
If that's not critical, why not for the moment use the global timer?
Thanks,
Mark.
Matthias Brugger
maintainerPATCH v2 7/9 arm: dts: mt6589: Add arm arch timer node
In reply to Matthias BruggerThis patch adds the device tree node for the arm architecture timer.
--- arch/arm/boot/dts/mt6589.dtsi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
arch/arm/boot/dts/mt6589.dtsi +11 -2
@@ -73,14 +73,23 @@ compatible = "simple-bus"; ranges; - timer: timer at 10008000 { + timer1: timer at 10008000 { compatible = "mediatek,mt6577-timer"; - reg = <0x10008000 0x80>; + reg = <0x10008000 0x60>; interrupts = <GIC_SPI 113 IRQ_TYPE_EDGE_RISING>; clocks = <&system_clk>, <&rtc_clk>; clock-names = "system-clk", "rtc-clk"; }; + timer2: timer { + compatible = "arm,armv7-timer"; + interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, + <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, + <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>, + <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>; + clock-frequency = <13000000>; + }; + gic: interrupt-controller at 10211000 { compatible = "arm,cortex-a15-gic"; interrupt-controller;
Signature · 1 line
1.7.9.5
Matthias Brugger
maintainerPATCH v2 8/9 arm: dts: mediatek: Add compatible property for aquaris5
In reply to Matthias BruggerAdd the missing 'compatible' property to device tree root node of
- mt6589-aquaris5.dts
and document the new values.
--- Documentation/devicetree/bindings/arm/mediatek.txt | 6 ++++++ arch/arm/boot/dts/mt6589-aquaris5.dts | 1 + 2 files changed, 7 insertions(+)
Documentation/devicetree/bindings/arm/mediatek.txt +6 -0
@@ -6,3 +6,9 @@ Required root node property: compatible: must contain "mediatek,mt6589" + +Supported boards: + +- bq Aquaris5 smart phone: + Required root node properties: + - compatible = "mundoreader,bq-aquaris5", "mediatek,mt6589";
arch/arm/boot/dts/mt6589-aquaris5.dts +1 -0
@@ -18,6 +18,7 @@ / { model = "bq Aquaris5"; + compatible = "mundoreader,bq-aquaris5", "mediatek,mt6589"; chosen { bootargs = "earlyprintk";
Signature · 1 line
1.7.9.5
Matthias Brugger
maintainerPATCH v2 9/9 arm: dts: mt6589: Change compatible string for GIC
In reply to Matthias BruggerThis patch changes the compatible string of the GIC to the new "arm,cortex-a7-gic" which does reflect the actual hardware.
--- arch/arm/boot/dts/mt6589.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/mt6589.dtsi +1 -1
@@ -91,7 +91,7 @@ }; gic: interrupt-controller at 10211000 { - compatible = "arm,cortex-a15-gic"; + compatible = "arm,cortex-a7-gic"; interrupt-controller; #interrupt-cells = <3>; reg = <0x10211000 0x1000>,
Signature · 1 line
1.7.9.5