Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Device Tree support for Mediatek SoCs
0004  *
0005  * Copyright (c) 2014 MundoReader S.L.
0006  * Author: Matthias Brugger <matthias.bgg@gmail.com>
0007  */
0008 #include <linux/init.h>
0009 #include <linux/io.h>
0010 #include <asm/mach/arch.h>
0011 #include <linux/of.h>
0012 #include <linux/of_clk.h>
0013 #include <linux/clocksource.h>
0014 
0015 
0016 #define GPT6_CON_MT65xx 0x10008060
0017 #define GPT_ENABLE      0x31
0018 
0019 static void __init mediatek_timer_init(void)
0020 {
0021     void __iomem *gpt_base;
0022 
0023     if (of_machine_is_compatible("mediatek,mt6589") ||
0024         of_machine_is_compatible("mediatek,mt7623") ||
0025         of_machine_is_compatible("mediatek,mt8135") ||
0026         of_machine_is_compatible("mediatek,mt8127")) {
0027         /* turn on GPT6 which ungates arch timer clocks */
0028         gpt_base = ioremap(GPT6_CON_MT65xx, 0x04);
0029 
0030         /* enable clock and set to free-run */
0031         writel(GPT_ENABLE, gpt_base);
0032         iounmap(gpt_base);
0033     }
0034 
0035     of_clk_init(NULL);
0036     timer_probe();
0037 };
0038 
0039 static const char * const mediatek_board_dt_compat[] = {
0040     "mediatek,mt2701",
0041     "mediatek,mt6589",
0042     "mediatek,mt6592",
0043     "mediatek,mt7623",
0044     "mediatek,mt7629",
0045     "mediatek,mt8127",
0046     "mediatek,mt8135",
0047     NULL,
0048 };
0049 
0050 DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
0051     .dt_compat  = mediatek_board_dt_compat,
0052     .init_time  = mediatek_timer_init,
0053 MACHINE_END