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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
/*
* Copyright (C) 2014 Freescale Semiconductor, Inc.
* Freescale IMX Linux-specific MCC implementation.
* iMX6sx-specific MCC library functions.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/regmap.h>
#include <linux/mcc_imx6sx.h>
#include <linux/mcc_linux.h>
/*!
* \brief This function returns the core number
*
* \return int
*/
unsigned int _psp_core_num(void)
{
return 0;
}
/*
* This field contains CPU-to-CPU interrupt vector numbers
* for all device cores.
*/
static const unsigned int mcc_cpu_to_cpu_vectors[] = {INT_CPU_TO_CPU_MU_A2M,
INT_CPU_TO_CPU_MU_M2A};
/*!
* \brief This function gets the CPU-to-CPU vector num for the particular core.
*
* Platform-specific inter-CPU vector numbers for each core are defined in the
* mcc_cpu_to_cpu_vectors[] field.
*
* \param[in] core Core number.
*
* \return vector number for the particular core
* \return MCC_VECTOR_NUMBER_INVALID (vector number for the particular core
* number not found)
*/
unsigned int mcc_get_cpu_to_cpu_vector(unsigned int core)
{
u32 val;
val = sizeof(mcc_cpu_to_cpu_vectors)/sizeof(mcc_cpu_to_cpu_vectors[0]);
if (core < val)
return mcc_cpu_to_cpu_vectors[core];
return MCC_VECTOR_NUMBER_INVALID;
}
/*!
* \brief This function clears the CPU-to-CPU int flag for the particular core.
*
* Implementation is platform-specific.
*
* \param[in] core Core number.
*/
void mcc_clear_cpu_to_cpu_interrupt(unsigned int core)
{
u32 val;
regmap_read(imx_mu_reg, MU_ASR, &val);
/* write 1 to BIT31 to clear the bit31(GIP3) of MU_ASR */
val = val | (1 << 31);
regmap_write(imx_mu_reg, MU_ASR, val);
}
/*!
* \brief This function triggers the CPU-to-CPU interrupt.
*
* Platform-specific software triggering the inter-CPU interrupts.
*/
void mcc_triger_cpu_to_cpu_interrupt(void)
{
int i = 0;
u32 val;
regmap_read(imx_mu_reg, MU_ACR, &val);
if ((val & BIT(19)) != 0) {
do {
regmap_read(imx_mu_reg, MU_ACR, &val);
msleep(1);
} while (((val & BIT(19)) > 0) && (i++ < 100));
}
if ((val & BIT(19)) == 0)
/* Enable the bit19(GIR3) of MU_ACR */
regmap_update_bits(imx_mu_reg, MU_ACR, BIT(19), BIT(19));
else
pr_info("mcc int still be triggered after %d ms polling!\n", i);
}
/*!
* \brief This function disable the CPU-to-CPU interrupt.
*
* Platform-specific software disable the inter-CPU interrupts.
*/
int imx_mcc_bsp_int_disable(unsigned int vector_number)
{
u32 val;
if (vector_number == INT_CPU_TO_CPU_MU_A2M) {
/* Disable the bit31(GIE3) of MU_ACR */
regmap_update_bits(imx_mu_reg, MU_ACR, BIT(31), 0);
/* flush */
regmap_read(imx_mu_reg, MU_ACR, &val);
} else
pr_err("ERR:wrong vector number in mcc.\n");
return 0;
}
/*!
* \brief This function enable the CPU-to-CPU interrupt.
*
* Platform-specific software enable the inter-CPU interrupts.
*/
int imx_mcc_bsp_int_enable(unsigned int vector_number)
{
u32 val;
if (vector_number == INT_CPU_TO_CPU_MU_A2M) {
/* Enable the bit31(GIE3) of MU_ACR */
regmap_update_bits(imx_mu_reg, MU_ACR, BIT(31), BIT(31));
/* flush */
regmap_read(imx_mu_reg, MU_ACR, &val);
return 0;
} else {
pr_err("ERR:wrong vector number in mcc.\n");
return -EINVAL;
}
}
|