1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2018 MediaTek Inc.
4 * Author: Ryder Lee <ryder.lee@mediatek.com>
12 #include <asm/arch/misc.h>
13 #include <asm/sections.h>
14 #include <dm/uclass.h>
17 #include <dt-bindings/clock/mt7629-clk.h>
19 #define L2_CFG_BASE 0x10200000
20 #define L2_CFG_SIZE 0x1000
21 #define L2_SHARE_CFG_MP0 0x7f0
22 #define L2_SHARE_MODE_OFF BIT(8)
24 DECLARE_GLOBAL_DATA_PTR;
26 int mtk_pll_early_init(void)
28 unsigned long pll_rates[] = {
29 [CLK_APMIXED_ARMPLL] = 1250000000,
30 [CLK_APMIXED_MAINPLL] = 1120000000,
31 [CLK_APMIXED_UNIV2PLL] = 1200000000,
32 [CLK_APMIXED_ETH1PLL] = 500000000,
33 [CLK_APMIXED_ETH2PLL] = 700000000,
34 [CLK_APMIXED_SGMIPLL] = 650000000,
39 ret = uclass_get_device_by_driver(UCLASS_CLK,
40 DM_GET_DRIVER(mtk_clk_apmixedsys), &dev);
44 /* configure default rate then enable apmixedsys */
45 for (i = 0; i < ARRAY_SIZE(pll_rates); i++) {
46 struct clk clk = { .id = i, .dev = dev };
48 ret = clk_set_rate(&clk, pll_rates[i]);
52 ret = clk_enable(&clk);
58 ret = uclass_get_device_by_driver(UCLASS_SYSCON,
59 DM_GET_DRIVER(mtk_mcucfg), &dev);
66 int mtk_soc_early_init(void)
71 /* initialize early clocks */
72 ret = mtk_pll_early_init();
76 ret = uclass_first_device_err(UCLASS_RAM, &dev);
83 int mach_cpu_init(void)
87 base = ioremap(L2_CFG_BASE, L2_CFG_SIZE);
89 /* disable L2C shared mode */
90 writel(L2_SHARE_MODE_OFF, base + L2_SHARE_CFG_MP0);
101 ret = uclass_first_device_err(UCLASS_RAM, &dev);
105 ret = ram_get_info(dev, &ram);
109 debug("RAM init base=%lx, size=%x\n", ram.base, ram.size);
111 gd->ram_size = ram.size;
116 int print_cpuinfo(void)
118 void __iomem *chipid;
121 chipid = ioremap(VER_BASE, VER_SIZE);
122 hwcode = readl(chipid + APHW_CODE);
123 swver = readl(chipid + APSW_VER);
125 printf("CPU: MediaTek MT%04x E%d\n", hwcode, (swver & 0xf) + 1);