1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2018 MediaTek Inc.
14 #include <asm/arch/misc.h>
15 #include <asm/sections.h>
16 #include <dm/uclass.h>
17 #include <linux/bitops.h>
20 #include <dt-bindings/clock/mt7629-clk.h>
22 #define L2_CFG_BASE 0x10200000
23 #define L2_CFG_SIZE 0x1000
24 #define L2_SHARE_CFG_MP0 0x7f0
25 #define L2_SHARE_MODE_OFF BIT(8)
27 DECLARE_GLOBAL_DATA_PTR;
29 int mtk_pll_early_init(void)
31 unsigned long pll_rates[] = {
32 [CLK_APMIXED_ARMPLL] = 1250000000,
33 [CLK_APMIXED_MAINPLL] = 1120000000,
34 [CLK_APMIXED_UNIV2PLL] = 1200000000,
35 [CLK_APMIXED_ETH1PLL] = 500000000,
36 [CLK_APMIXED_ETH2PLL] = 700000000,
37 [CLK_APMIXED_SGMIPLL] = 650000000,
42 ret = uclass_get_device_by_driver(UCLASS_CLK,
43 DM_DRIVER_GET(mtk_clk_apmixedsys), &dev);
47 /* configure default rate then enable apmixedsys */
48 for (i = 0; i < ARRAY_SIZE(pll_rates); i++) {
49 struct clk clk = { .id = i, .dev = dev };
51 ret = clk_set_rate(&clk, pll_rates[i]);
55 ret = clk_enable(&clk);
61 ret = uclass_get_device_by_driver(UCLASS_SYSCON,
62 DM_DRIVER_GET(mtk_mcucfg), &dev);
69 int mtk_soc_early_init(void)
74 /* initialize early clocks */
75 ret = mtk_pll_early_init();
79 ret = uclass_first_device_err(UCLASS_RAM, &dev);
86 int mach_cpu_init(void)
90 base = ioremap(L2_CFG_BASE, L2_CFG_SIZE);
92 /* disable L2C shared mode */
93 writel(L2_SHARE_MODE_OFF, base + L2_SHARE_CFG_MP0);
104 ret = uclass_first_device_err(UCLASS_RAM, &dev);
108 ret = ram_get_info(dev, &ram);
112 debug("RAM init base=%lx, size=%x\n", ram.base, ram.size);
114 gd->ram_size = ram.size;
119 int print_cpuinfo(void)
121 void __iomem *chipid;
124 chipid = ioremap(VER_BASE, VER_SIZE);
125 hwcode = readl(chipid + APHW_CODE);
126 swver = readl(chipid + APSW_VER);
128 printf("CPU: MediaTek MT%04x E%d\n", hwcode, (swver & 0xf) + 1);