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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
/*
* Copyright (C) 2013 Spreadtrum Communications Inc.
* Copyright (C) steve.zhan
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that 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.
*
*/
#define SCX35_ALPHA_TAPOUT (0x8300aaaa)
#define SCX35_ALPHA_TAPOUT_MASK (0xFFFFFFFF)
#define SCX35_BETA_TAPOUT (0x8300a001)
#define SCX35_BETA_TAPOUT_MASK (0xFFFFFFFF)
#define SCX35G_ALPHA_TAPOUT (0x8730b000)
#define SCX35G_ALPHA_TAPOUT_MASK (0xFFFFF000)
#define SCX30G2_ALPHA_TAPOUT (0x8730C000)
#define SCX30G2_ALPHA_TAPOUT_MASK (0xFFFFF000)
#define SCX9630_ALPHA_TAPOUT (0x96300000)
#define SCX9630_ALPHA_TAPOUT_MASK (0xFFFFF000)
#define SCX35L64_ALPHA_TAPOUT (0x96310000)
#define SCX35L64_ALPHA_TAPOUT_MASK (0xFFFF0000)
#define SCX9820_ALPHA_TAPOUT (0x96320000)
#define SCX9820_ALPHA_TAPOUT_MASK (0xFFFF0000)
#define SCX7720_ALPHA_TAPOUT (0x88600000)
#define SCX7720_ALPHA_TAPOUT_MASK (0xFFFF0000)
#define SCX9830I_ALPHA_TAPOUT (0x6b4c5300)
#define SCX9830I_ALPHA_TAPOUT_MASK (0xFFFFFFFF)
/**
* sci_get_chip_id - read chip id
*
*
* Return read the chip id
*/
u32 sci_get_chip_id(void);
/**
* sci_get_ana_chip_id - read a-die chip id
*
* Return the a-die chip id, example: 0X2711A000
*/
u32 sci_get_ana_chip_id(void);
#define MASK_ANA_VER ( 0xFFF )
enum sci_ana_chip_ver {
SC2711AA = 0x000,
SC2711AB = 0x000, /* discard */
SC2711AC = 0x002,
SC2711BA = 0x100,
SC2713CA = 0xA00,
/* SC2723 */
SC2723ES = 0x090,
SC2723TS = 0x0C0,
//TODO: Add more ana chip version here
};
/**
* sci_get_ana_chip_ver - read a-die chip version
*
* Return the a-die chip version, example: 0X100
*/
int sci_get_ana_chip_ver(void);
/**
* sci_ana_chip_vers_is_compatible
*
* Check if the given "chip_ver" string matches the a-die chip on board
*/
static inline int sci_ana_chip_ver_is_compatible(enum sci_ana_chip_ver compat)
{
return sci_get_ana_chip_ver() == (u32)compat;
}
/**
*
* sc_init_chip_id(void) - read chip id from hardware and save it.
*
*/
void __init sc_init_chip_id(void);
void set_section_ro(unsigned long virt, unsigned long numsections);
#define IS_CPU(name, id, mask) \
static inline int soc_id_is_##name(void) \
{ \
pr_info("chip id is %x\n",sci_get_chip_id()); \
return ((sci_get_chip_id() & mask) == (id & mask)); \
}
IS_CPU(sc8735v0, SCX35_ALPHA_TAPOUT, SCX35_ALPHA_TAPOUT_MASK)
IS_CPU(sc8735v1, SCX35_BETA_TAPOUT, SCX35_BETA_TAPOUT_MASK)
IS_CPU(sc8735gv0, SCX35G_ALPHA_TAPOUT, SCX35G_ALPHA_TAPOUT_MASK)
IS_CPU(sc8730g2v0, SCX30G2_ALPHA_TAPOUT, SCX30G2_ALPHA_TAPOUT_MASK)
IS_CPU(sc9631v0, SCX35L64_ALPHA_TAPOUT, SCX35L64_ALPHA_TAPOUT_MASK)
IS_CPU(sc9630v0, SCX9630_ALPHA_TAPOUT, SCX9630_ALPHA_TAPOUT_MASK)
IS_CPU(sc9820v0, SCX9820_ALPHA_TAPOUT, SCX9820_ALPHA_TAPOUT_MASK)
IS_CPU(sc7720v0, SCX7720_ALPHA_TAPOUT, SCX7720_ALPHA_TAPOUT_MASK)
IS_CPU(sc9830iv0, SCX9830I_ALPHA_TAPOUT, SCX9830I_ALPHA_TAPOUT_MASK)
/*Driver can use this MACRO to distinguish different chip code */
#define soc_is_scx35_v0() soc_id_is_sc8735v0()
#define soc_is_scx35_v1() soc_id_is_sc8735v1()
#define soc_is_scx35g_v0() soc_id_is_sc8735gv0()
#define soc_is_scx30g2_v0() soc_id_is_sc8730g2v0()
#define soc_is_scx35l64_v0() soc_id_is_sc9631v0()
#define soc_is_scx9630_v0() soc_id_is_sc9630v0()
#define soc_is_scx9820_v0() soc_id_is_sc9820v0()
#define soc_is_scx7720_v0() soc_id_is_sc7720v0()
#define soc_is_scx9830i_v0() soc_id_is_sc9830iv0()
/**
* read value from virtual address. Pls make sure val is not NULL.
* return 0 is successful
*/
int sci_read_va(ulong vreg, ulong *val);
/**
* write value to virtual address. if clear_msk is ~0, or_val will fully set to vreg.
* return 0 is successful
*/
int sci_write_va(ulong vreg, const ulong or_val, const u32 clear_msk);
/**
* read value from pysical address. Pls make sure val is not NULL.
* return 0 is successful
*/
int sci_read_pa(ulong preg, ulong *val);
/**
* write value to pysical address. if clear_msk is ~0, or_val will fully set to paddr.
* return 0 is successful
*/
int sci_write_pa(ulong paddr, const ulong or_val, const u32 clear_msk);
#define SPRD_CHIPID_7715 (0x77150000)
#define SPRD_CHIPID_8815 (0X88150000)
static inline int soc_is_sc7715(void)
{
unsigned int flag = 0;
flag = sci_get_chip_id() & 0xffff0000;
if ((SPRD_CHIPID_7715 == flag)
||(SPRD_CHIPID_8815 == flag))
{
return 1;
}
else
{
pr_err("%s error chip id\n", __func__);
return 0;
}
}
|