mtk_ptp3_main.c 1.94 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * Copyright (c) 2020, MediaTek Inc. All rights reserved. \
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "mtk_ptp3_common.h"

/************************************************
 * Central control: turn on sysPi protection
 ************************************************/
static unsigned int ptp3_cfg1[NR_PTP3_CFG1_CPU][NR_PTP3_CFG] = {
	{0x0C530610, 0x110842},
	{0x0C530E10, 0x110842},
	{0x0C531610, 0x110842},
	{0x0C531E10, 0x110842},
	{0x0C532610, 0x110842},
	{0x0C532E10, 0x110842},
	{0x0C533610, 0x110842},
	{0x0C533E10, 0x110842}
};
static unsigned int ptp3_cfg2[NR_PTP3_CFG2_CPU][NR_PTP3_CFG] = {
	{0x0C53B830, 0x68000},
	{0x0C53BA30, 0x68000},
	{0x0C53BC30, 0x68000},
	{0x0C53BE30, 0x68000}
};
static unsigned int ptp3_cfg3[NR_PTP3_CFG3_CPU][NR_PTP3_CFG] = {
	{0x0C532480, 0x7C607C6},
	{0x0C532C80, 0x7C607C6},
	{0x0C533480, 0x7C607C6},
	{0x0C533C80, 0x7C607C6}
};

/************************************************
 * API
 ************************************************/
void ptp3_init(unsigned int core)
{
	unsigned int _core;

	if (core >= PTP3_CFG1_CPU_START_ID) {
		if (core < NR_PTP3_CFG1_CPU) {
			/* update ptp3_cfg1 */
			ptp3_write(
				ptp3_cfg1[core][PTP3_CFG_ADDR],
				ptp3_cfg1[core][PTP3_CFG_VALUE]);
		}
	}

	if (core >= PTP3_CFG2_CPU_START_ID) {
		_core = core - PTP3_CFG2_CPU_START_ID;

		if (_core < NR_PTP3_CFG2_CPU) {
			/* update ptp3_cfg2 */
			ptp3_write(
				ptp3_cfg2[_core][PTP3_CFG_ADDR],
				ptp3_cfg2[_core][PTP3_CFG_VALUE]);
		}
	}

	if (core >= PTP3_CFG3_CPU_START_ID) {
		_core = core - PTP3_CFG3_CPU_START_ID;

		if (_core < NR_PTP3_CFG3_CPU) {
			/* update ptp3_cfg3 */
			ptp3_write(
				ptp3_cfg3[_core][PTP3_CFG_ADDR],
				ptp3_cfg3[_core][PTP3_CFG_VALUE]);
		}
	}
}

void ptp3_deinit(unsigned int core)
{
	if (core >= PTP3_CFG1_CPU_START_ID) {
		if (core < NR_PTP3_CFG1_CPU) {
			/* update ptp3_cfg1 */
			ptp3_write(
				ptp3_cfg1[core][PTP3_CFG_ADDR],
				ptp3_cfg1[core][PTP3_CFG_VALUE] &
					 ~PTP3_CFG1_MASK);
		}
	}
}