blob: f46435c74b2b5f9d9bf2171acabc39231ed45d86 [file] [log] [blame]
TracyMg_Li734d5772023-12-25 11:21:34 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2023, Phytium Technology Co., Ltd.
4 * lixinde <lixinde@phytium.com.cn>
5 * weichangzheng <weichangzheng@phytium.com.cn>
6 */
7
8#include <stdio.h>
9#include <string.h>
10#include <asm/io.h>
11#include <linux/arm-smccc.h>
12#include <init.h>
13#include "cpu.h"
14
15struct pll_config {
16 u32 magic;
17 u32 version;
18 u32 size;
19 u8 rev1[4];
20 u32 clust0_pll;
21 u32 clust1_pll;
22 u32 clust2_pll;
23 u32 noc_pll;
24 u32 dmu_pll;
25} __attribute((aligned(4)));
26
27struct pll_config const pll_base_info = {
28 .magic = PARAMETER_PLL_MAGIC,
29 .version = 0x2,
30 .size = 0x100,
31 .clust0_pll = 2000,
32 .clust1_pll = 2000,
33 .clust2_pll = 2000,
34 .noc_pll = 1800,
35 .dmu_pll = 600,
36};
37
38u32 get_reset_source(void)
39{
40 struct arm_smccc_res res;
41
42 arm_smccc_smc(CPU_GET_RST_SOURCE, 0, 0, 0, 0, 0, 0, 0, &res);
43
44 return res.a0;
45}
46
47void pll_init(void)
48{
49 u8 buffer[0x100];
50 struct arm_smccc_res res;
51
52 memcpy(buffer, &pll_base_info, sizeof(pll_base_info));
53 arm_smccc_smc(CPU_INIT_PLL, 0, (u64)buffer, 0, 0, 0, 0, 0, &res);
54 if (res.a0 != 0)
55 panic("PLL init failed :0x%lx\n", res.a0);
56}
57
58void check_reset(void)
59{
60 u32 rst;
61
62 rst = get_reset_source();
63
64 switch (rst) {
65 case CPU_RESET_POWER_ON:
66 pll_init();
67 break;
68 case CPU_RESET_PLL:
69 break;
70 case CPU_RESET_WATCH_DOG:
71 break;
72 default:
73 panic("other reset source\n");
74 }
75}