2 * Copyright (C) 2013 Spreadtrum Communications Inc.
3 * Copyright (C) steve.zhan
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #define SCX35_ALPHA_TAPOUT (0x8300aaaa)
18 #define SCX35_ALPHA_TAPOUT_MASK (0xFFFFFFFF)
20 #define SCX35_BETA_TAPOUT (0x8300a001)
21 #define SCX35_BETA_TAPOUT_MASK (0xFFFFFFFF)
23 #define SCX35G_ALPHA_TAPOUT (0x8730b000)
24 #define SCX35G_ALPHA_TAPOUT_MASK (0xFFFFF000)
26 #define SCX30G2_ALPHA_TAPOUT (0x8730C000)
27 #define SCX30G2_ALPHA_TAPOUT_MASK (0xFFFFF000)
29 #define SCX9630_ALPHA_TAPOUT (0x96300000)
30 #define SCX9630_ALPHA_TAPOUT_MASK (0xFFFFF000)
32 #define SCX35L64_ALPHA_TAPOUT (0x96310000)
33 #define SCX35L64_ALPHA_TAPOUT_MASK (0xFFFF0000)
35 #define SCX9820_ALPHA_TAPOUT (0x96320000)
36 #define SCX9820_ALPHA_TAPOUT_MASK (0xFFFF0000)
38 #define SCX7720_ALPHA_TAPOUT (0x88600000)
39 #define SCX7720_ALPHA_TAPOUT_MASK (0xFFFF0000)
41 * sci_get_chip_id - read chip id
44 * Return read the chip id
46 u32 sci_get_chip_id(void);
49 * sci_get_ana_chip_id - read a-die chip id
51 * Return the a-die chip id, example: 0X2711A000
53 u32 sci_get_ana_chip_id(void);
55 #define MASK_ANA_VER ( 0xFFF )
56 enum sci_ana_chip_ver {
58 SC2711AB = 0x000, /* discard */
66 //TODO: Add more ana chip version here
70 * sci_get_ana_chip_ver - read a-die chip version
72 * Return the a-die chip version, example: 0X100
74 int sci_get_ana_chip_ver(void);
77 * sci_ana_chip_vers_is_compatible
79 * Check if the given "chip_ver" string matches the a-die chip on board
81 static inline int sci_ana_chip_ver_is_compatible(enum sci_ana_chip_ver compat)
83 return sci_get_ana_chip_ver() == (u32)compat;
88 * sc_init_chip_id(void) - read chip id from hardware and save it.
91 void __init sc_init_chip_id(void);
93 void set_section_ro(unsigned long virt, unsigned long numsections);
96 #define IS_CPU(name, id, mask) \
97 static inline int soc_id_is_##name(void) \
99 pr_info("chip id is %x\n",sci_get_chip_id()); \
100 return ((sci_get_chip_id() & mask) == (id & mask)); \
103 IS_CPU(sc8735v0, SCX35_ALPHA_TAPOUT, SCX35_ALPHA_TAPOUT_MASK)
104 IS_CPU(sc8735v1, SCX35_BETA_TAPOUT, SCX35_BETA_TAPOUT_MASK)
105 IS_CPU(sc8735gv0, SCX35G_ALPHA_TAPOUT, SCX35G_ALPHA_TAPOUT_MASK)
106 IS_CPU(sc8730g2v0, SCX30G2_ALPHA_TAPOUT, SCX30G2_ALPHA_TAPOUT_MASK)
107 IS_CPU(sc9631v0, SCX35L64_ALPHA_TAPOUT, SCX35L64_ALPHA_TAPOUT_MASK)
108 IS_CPU(sc9630v0, SCX9630_ALPHA_TAPOUT, SCX9630_ALPHA_TAPOUT_MASK)
109 IS_CPU(sc9820v0, SCX9820_ALPHA_TAPOUT, SCX9820_ALPHA_TAPOUT_MASK)
110 IS_CPU(sc7720v0, SCX7720_ALPHA_TAPOUT, SCX7720_ALPHA_TAPOUT_MASK)
112 /*Driver can use this MACRO to distinguish different chip code */
113 #define soc_is_scx35_v0() soc_id_is_sc8735v0()
114 #define soc_is_scx35_v1() soc_id_is_sc8735v1()
115 #define soc_is_scx35g_v0() soc_id_is_sc8735gv0()
116 #define soc_is_scx30g2_v0() soc_id_is_sc8730g2v0()
117 #define soc_is_scx35l64_v0() soc_id_is_sc9631v0()
118 #define soc_is_scx9630_v0() soc_id_is_sc9630v0()
119 #define soc_is_scx9820_v0() soc_id_is_sc9820v0()
120 #define soc_is_scx7720_v0() soc_id_is_sc7720v0()
123 * read value from virtual address. Pls make sure val is not NULL.
124 * return 0 is successful
126 int sci_read_va(ulong vreg, ulong *val);
129 * write value to virtual address. if clear_msk is ~0, or_val will fully set to vreg.
130 * return 0 is successful
132 int sci_write_va(ulong vreg, const ulong or_val, const u32 clear_msk);
135 * read value from pysical address. Pls make sure val is not NULL.
136 * return 0 is successful
138 int sci_read_pa(ulong preg, ulong *val);
141 * write value to pysical address. if clear_msk is ~0, or_val will fully set to paddr.
142 * return 0 is successful
144 int sci_write_pa(ulong paddr, const ulong or_val, const u32 clear_msk);
146 #define SPRD_CHIPID_7715 (0x77150000)
147 #define SPRD_CHIPID_8815 (0X88150000)
149 static inline int soc_is_sc7715(void)
151 unsigned int flag = 0;
152 flag = sci_get_chip_id() & 0xffff0000;
153 if ((SPRD_CHIPID_7715 == flag)
154 ||(SPRD_CHIPID_8815 == flag))
160 pr_err("%s error chip id\n", __func__);