blob: a4d3be4ff09f1543772bd2a2a7a62d10d399b50d [file] [log] [blame]
vijay kumar27c6aab2015-12-11 16:23:25 +05301/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
Shashank Mittala635abf2012-03-28 18:11:43 -07002 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
Channagoud Kadabiafd62bf2013-01-08 20:32:52 -080012 * * Neither the name of The Linux Foundation, Inc. nor the names of its
Shashank Mittala635abf2012-03-28 18:11:43 -070013 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#include <debug.h>
31#include <board.h>
32#include <smem.h>
33#include <baseband.h>
Sridhar Parasuramf2348af2014-11-18 16:16:57 -080034#include <boot_device.h>
Shashank Mittala635abf2012-03-28 18:11:43 -070035
Sridhar Parasuram701c8302015-06-15 11:03:14 -070036static uint16_t format_major = 0;
37static uint16_t format_minor = 0;
38
Shashank Mittala635abf2012-03-28 18:11:43 -070039static struct board_data board = {UNKNOWN,
Channagoud Kadabibc0e47e2013-02-15 19:41:21 -080040 0,
Sundarajan Srinivasan763c0db2014-05-20 17:08:36 -070041 0,
Sridhar Parasuramc5f035f2014-10-22 12:37:36 -070042 0,
Shashank Mittala635abf2012-03-28 18:11:43 -070043 HW_PLATFORM_UNKNOWN,
44 HW_PLATFORM_SUBTYPE_UNKNOWN,
Amol Jadi5c61a952012-05-04 17:05:35 -070045 LINUX_MACHTYPE_UNKNOWN,
Deepa Dinamanib8b16432012-08-24 15:48:45 -070046 BASEBAND_MSM,
Veera Sundaram Sankaran00181512014-12-09 11:23:39 -080047 {{PMIC_IS_INVALID, 0, 0}, {PMIC_IS_INVALID, 0, 0},
48 {PMIC_IS_INVALID, 0, 0}},
vijay kumar4f4405f2014-08-08 11:49:53 +053049 0,
Sridhar Parasuram701c8302015-06-15 11:03:14 -070050 0,
51 0,
52 NULL,
Channagoud Kadabibc0e47e2013-02-15 19:41:21 -080053};
Shashank Mittala635abf2012-03-28 18:11:43 -070054
55static void platform_detect()
56{
57 struct smem_board_info_v6 board_info_v6;
Deepa Dinamania4ebcff2012-06-11 11:59:30 -070058 struct smem_board_info_v7 board_info_v7;
Channagoud Kadabibc0e47e2013-02-15 19:41:21 -080059 struct smem_board_info_v8 board_info_v8;
Sridhar Parasuramece28052014-11-18 09:03:08 -080060 struct smem_board_info_v9 board_info_v9;
61 struct smem_board_info_v10 board_info_v10;
Sridhar Parasuram701c8302015-06-15 11:03:14 -070062 struct smem_board_info_v11 board_info_v11;
Shashank Mittala635abf2012-03-28 18:11:43 -070063 unsigned int board_info_len = 0;
64 unsigned ret = 0;
65 unsigned format = 0;
Lijuan Gao9f152862014-08-18 13:45:24 +080066 unsigned pmic_type = 0;
Channagoud Kadabibc0e47e2013-02-15 19:41:21 -080067 uint8_t i;
Shashank Mittala635abf2012-03-28 18:11:43 -070068
69 ret = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
70 &format, sizeof(format), 0);
71 if (ret)
72 return;
73
Channagoud Kadabi4f370b42014-05-21 16:06:59 -070074 /* Extract the major & minor version info,
75 * Upper two bytes: major info
76 * Lower two byets: minor info
77 */
78 format_major = (format & 0xffff0000) >> 16;
79 format_minor = format & 0x0000ffff;
80
81 if (format_major == 0x0)
Deepa Dinamania4ebcff2012-06-11 11:59:30 -070082 {
Channagoud Kadabi4f370b42014-05-21 16:06:59 -070083 if (format_minor == 6)
84 {
Deepa Dinamania4ebcff2012-06-11 11:59:30 -070085 board_info_len = sizeof(board_info_v6);
Shashank Mittala635abf2012-03-28 18:11:43 -070086
Channagoud Kadabi4f370b42014-05-21 16:06:59 -070087 ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
88 &board_info_v6,
89 board_info_len);
90 if (ret)
91 return;
Shashank Mittala635abf2012-03-28 18:11:43 -070092
Channagoud Kadabi4f370b42014-05-21 16:06:59 -070093 board.platform = board_info_v6.board_info_v3.msm_id;
94 board.platform_version = board_info_v6.board_info_v3.msm_version;
95 board.platform_hw = board_info_v6.board_info_v3.hw_platform;
96 board.platform_subtype = board_info_v6.platform_subtype;
97 }
98 else if (format_minor == 7)
99 {
100 board_info_len = sizeof(board_info_v7);
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700101
Channagoud Kadabi4f370b42014-05-21 16:06:59 -0700102 ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
103 &board_info_v7,
104 board_info_len);
105 if (ret)
106 return;
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700107
Channagoud Kadabi4f370b42014-05-21 16:06:59 -0700108 board.platform = board_info_v7.board_info_v3.msm_id;
109 board.platform_version = board_info_v7.board_info_v3.msm_version;
110 board.platform_hw = board_info_v7.board_info_v3.hw_platform;
111 board.platform_subtype = board_info_v7.platform_subtype;
112 board.pmic_info[0].pmic_type = board_info_v7.pmic_type;
113 board.pmic_info[0].pmic_version = board_info_v7.pmic_version;
114 }
Sridhar Parasuramece28052014-11-18 09:03:08 -0800115 else if (format_minor == 8)
Channagoud Kadabi4f370b42014-05-21 16:06:59 -0700116 {
Channagoud Kadabi4f370b42014-05-21 16:06:59 -0700117 board_info_len = sizeof(board_info_v8);
Channagoud Kadabibc0e47e2013-02-15 19:41:21 -0800118
Channagoud Kadabi4f370b42014-05-21 16:06:59 -0700119 ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
120 &board_info_v8,
121 board_info_len);
122 if (ret)
123 return;
Channagoud Kadabibc0e47e2013-02-15 19:41:21 -0800124
Channagoud Kadabi4f370b42014-05-21 16:06:59 -0700125 board.platform = board_info_v8.board_info_v3.msm_id;
126 board.platform_version = board_info_v8.board_info_v3.msm_version;
127 board.platform_hw = board_info_v8.board_info_v3.hw_platform;
128 board.platform_subtype = board_info_v8.platform_subtype;
Maria Yuca51ee22013-06-27 21:45:24 +0800129
Channagoud Kadabi4f370b42014-05-21 16:06:59 -0700130 /*
131 * fill in board.target with variant_id information
132 * bit no |31 24 | 23 16 | 15 8 |7 0|
133 * board.target = |subtype| plat_hw_ver major | plat_hw_ver minor |hw_platform|
134 *
135 */
136 board.target = (((board_info_v8.platform_subtype & 0xff) << 24) |
137 (((board_info_v8.platform_version >> 16) & 0xff) << 16) |
138 ((board_info_v8.platform_version & 0xff) << 8) |
139 (board_info_v8.board_info_v3.hw_platform & 0xff));
140
141 for (i = 0; i < SMEM_V8_SMEM_MAX_PMIC_DEVICES; i++) {
142 board.pmic_info[i].pmic_type = board_info_v8.pmic_info[i].pmic_type;
143 board.pmic_info[i].pmic_version = board_info_v8.pmic_info[i].pmic_version;
Lijuan Gao9f152862014-08-18 13:45:24 +0800144
145 /*
146 * fill in pimc_board_info with pmic type and pmic version information
147 * bit no |31 24 | 23 16 | 15 8 |7 0|
148 * pimc_board_info = |Unused | Major version | Minor version|PMIC_MODEL|
149 *
150 */
151 pmic_type = board_info_v8.pmic_info[i].pmic_type == PMIC_IS_INVALID? 0 : board_info_v8.pmic_info[i].pmic_type;
152
153 board.pmic_info[i].pmic_target = (((board_info_v8.pmic_info[i].pmic_version >> 16) & 0xff) << 16) |
154 ((board_info_v8.pmic_info[i].pmic_version & 0xff) << 8) | (pmic_type & 0xff);
Channagoud Kadabi4f370b42014-05-21 16:06:59 -0700155 }
Sridhar Parasuramece28052014-11-18 09:03:08 -0800156 }
157 else if (format_minor == 0x9)
158 {
159 board_info_len = sizeof(board_info_v9);
Sundarajan Srinivasan763c0db2014-05-20 17:08:36 -0700160
Sridhar Parasuramece28052014-11-18 09:03:08 -0800161 ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
162 &board_info_v9,
163 board_info_len);
164 if (ret)
165 return;
Sridhar Parasuramc5f035f2014-10-22 12:37:36 -0700166
Sridhar Parasuramece28052014-11-18 09:03:08 -0800167 board.platform = board_info_v9.board_info_v3.msm_id;
168 board.platform_version = board_info_v9.board_info_v3.msm_version;
169 board.platform_hw = board_info_v9.board_info_v3.hw_platform;
170 board.platform_subtype = board_info_v9.platform_subtype;
171
172 /*
173 * fill in board.target with variant_id information
174 * bit no |31 24 | 23 16 | 15 8 |7 0|
175 * board.target = |subtype| plat_hw_ver major | plat_hw_ver minor |hw_platform|
176 *
177 */
178 board.target = (((board_info_v9.platform_subtype & 0xff) << 24) |
179 (((board_info_v9.platform_version >> 16) & 0xff) << 16) |
180 ((board_info_v9.platform_version & 0xff) << 8) |
181 (board_info_v9.board_info_v3.hw_platform & 0xff));
182
183 for (i = 0; i < SMEM_V8_SMEM_MAX_PMIC_DEVICES; i++) {
184 board.pmic_info[i].pmic_type = board_info_v9.pmic_info[i].pmic_type;
185 board.pmic_info[i].pmic_version = board_info_v9.pmic_info[i].pmic_version;
186
187 /*
188 * fill in pimc_board_info with pmic type and pmic version information
189 * bit no |31 24 | 23 16 | 15 8 |7 0|
190 * pimc_board_info = |Unused | Major version | Minor version|PMIC_MODEL|
191 *
192 */
193 pmic_type = board_info_v9.pmic_info[i].pmic_type == PMIC_IS_INVALID? 0 : board_info_v9.pmic_info[i].pmic_type;
194
195 board.pmic_info[i].pmic_target = (((board_info_v9.pmic_info[i].pmic_version >> 16) & 0xff) << 16) |
196 ((board_info_v9.pmic_info[i].pmic_version & 0xff) << 8) | (pmic_type & 0xff);
197 }
198 board.foundry_id = board_info_v9.foundry_id;
199 }
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700200 else if (format_minor == 0xA)
Sridhar Parasuramece28052014-11-18 09:03:08 -0800201 {
202 board_info_len = sizeof(board_info_v10);
203
204 ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
205 &board_info_v10,
206 board_info_len);
207 if (ret)
208 return;
209
210 board.platform = board_info_v10.board_info_v3.msm_id;
211 board.platform_version = board_info_v10.board_info_v3.msm_version;
212 board.platform_hw = board_info_v10.board_info_v3.hw_platform;
213 board.platform_subtype = board_info_v10.platform_subtype;
214
215 /*
216 * fill in board.target with variant_id information
217 * bit no |31 24 | 23 16 | 15 8 |7 0|
218 * board.target = |subtype| plat_hw_ver major | plat_hw_ver minor |hw_platform|
219 *
220 */
221 board.target = (((board_info_v10.platform_subtype & 0xff) << 24) |
222 (((board_info_v10.platform_version >> 16) & 0xff) << 16) |
223 ((board_info_v10.platform_version & 0xff) << 8) |
224 (board_info_v10.board_info_v3.hw_platform & 0xff));
225
226 for (i = 0; i < SMEM_V8_SMEM_MAX_PMIC_DEVICES; i++) {
227 board.pmic_info[i].pmic_type = board_info_v10.pmic_info[i].pmic_type;
228 board.pmic_info[i].pmic_version = board_info_v10.pmic_info[i].pmic_version;
229
230 /*
231 * fill in pimc_board_info with pmic type and pmic version information
232 * bit no |31 24 | 23 16 | 15 8 |7 0|
233 * pimc_board_info = |Unused | Major version | Minor version|PMIC_MODEL|
234 *
235 */
236 pmic_type = board_info_v10.pmic_info[i].pmic_type == PMIC_IS_INVALID? 0 : board_info_v10.pmic_info[i].pmic_type;
237
238 board.pmic_info[i].pmic_target = (((board_info_v10.pmic_info[i].pmic_version >> 16) & 0xff) << 16) |
239 ((board_info_v10.pmic_info[i].pmic_version & 0xff) << 8) | (pmic_type & 0xff);
240 }
241 board.foundry_id = board_info_v10.foundry_id;
242 board.chip_serial = board_info_v10.chip_serial;
Channagoud Kadabibc0e47e2013-02-15 19:41:21 -0800243 }
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700244 else if (format_minor >= 0xB)
245 {
246 board_info_len = sizeof(board_info_v11);
247
248 ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
249 &board_info_v11,
250 board_info_len);
251 if (ret)
252 return;
253
254 board.platform = board_info_v11.board_info_v3.msm_id;
255 board.platform_version = board_info_v11.board_info_v3.msm_version;
256 board.platform_hw = board_info_v11.board_info_v3.hw_platform;
257 board.platform_subtype = board_info_v11.platform_subtype;
258 /*
259 * fill in board.target with variant_id information
260 * bit no |31 24 |23 16|15 8|7 0|
261 * board.target = |subtype|plat_hw_ver major|plat_hw_ver minor|hw_platform|
262 *
263 */
264
265 board.target = (((board_info_v11.platform_subtype & 0xff) << 24) |
266 (((board_info_v11.platform_version >> 16) & 0xff) << 16) |
267 ((board_info_v11.platform_version & 0xff) << 8) |
268 (board_info_v11.board_info_v3.hw_platform & 0xff));
269
270 board.foundry_id = board_info_v11.foundry_id;
271 board.chip_serial = board_info_v11.chip_serial;
272 board.num_pmics = board_info_v11.num_pmics;
273 board.pmic_array_offset = board_info_v11.pmic_array_offset;
274 }
Aparna Mallavarapu6eb30902014-05-13 17:03:10 +0530275
276 /* HLOS subtype
Unnati Gandhi24885052014-11-27 16:57:49 +0530277 * bit no |31 20 | 19 16|15 13 |12 11 | 10 8 | 7 0|
278 * board.platform_hlos_subtype = |reserved | Boot device |Reserved | Panel | DDR detection | subtype|
279 * | bits | | bits | Detection |
Aparna Mallavarapu6eb30902014-05-13 17:03:10 +0530280 */
Unnati Gandhi24885052014-11-27 16:57:49 +0530281 board.platform_hlos_subtype = (board_get_ddr_subtype() << 8) | (platform_get_boot_dev() << 16) | (platform_detect_panel() << 11);
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700282 }
283 else
284 {
Channagoud Kadabi4f370b42014-05-21 16:06:59 -0700285 dprintf(CRITICAL, "Unsupported board info format %u.%u\n", format_major, format_minor);
Deepa Dinamania4ebcff2012-06-11 11:59:30 -0700286 ASSERT(0);
Shashank Mittala635abf2012-03-28 18:11:43 -0700287 }
288}
289
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700290void pmic_info_populate()
291{
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700292 uint32_t pmic_type = 0;
vijay kumar27c6aab2015-12-11 16:23:25 +0530293 void *smem_board_info_addr = NULL;
294 uint32_t smem_board_info_size = 0;
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700295
296 if (format_minor < 0xB)
297 {
298 // not needed for smem versions < 0xB
299 return;
300 }
vijay kumar27c6aab2015-12-11 16:23:25 +0530301 smem_board_info_addr = smem_get_alloc_entry(SMEM_BOARD_INFO_LOCATION, &smem_board_info_size);
302 if (smem_board_info_addr == NULL)
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700303 {
vijay kumar27c6aab2015-12-11 16:23:25 +0530304 dprintf(CRITICAL, "Error reading the smem board info address\n");
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700305 ASSERT(0);
306 }
vijay kumar27c6aab2015-12-11 16:23:25 +0530307
308 if (smem_board_info_size < board.pmic_array_offset)
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700309 {
vijay kumar27c6aab2015-12-11 16:23:25 +0530310 dprintf(CRITICAL, "Invalid SMEM board info\n");
311 ASSERT(0);
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700312 }
313
314 if(!(board.pmic_info_array = malloc(board.num_pmics * sizeof(struct board_pmic_data))))
315 {
316 dprintf(CRITICAL, "Error allocating memory for pmic info array\n");
317 ASSERT(0);
318 }
vijay kumar27c6aab2015-12-11 16:23:25 +0530319
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700320 struct board_pmic_data *info = board.pmic_info_array;
321 for (uint8_t i = 0; i < board.num_pmics; i++)
322 {
vijay kumar27c6aab2015-12-11 16:23:25 +0530323 memcpy(info, smem_board_info_addr + board.pmic_array_offset + (i * sizeof(struct smem_pmic_info)), sizeof(struct smem_pmic_info));
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700324 /*
325 * fill in pimc_board_info with pmic type and pmic version information
326 * bit no |31 24|23 16|15 8|7 0|
327 * pimc_board_info = |Unused|Major version|Minor version|PMIC_MODEL|
328 *
329 */
330 pmic_type = info->pmic_type == PMIC_IS_INVALID? 0 : info->pmic_type;
331 info->pmic_target = (((info->pmic_version >> 16) & 0xff) << 16) |
332 ((info->pmic_version & 0xff) << 8) | (pmic_type & 0xff);
333 info++;
334 }
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700335}
336
Shashank Mittala635abf2012-03-28 18:11:43 -0700337void board_init()
338{
339 platform_detect();
Amol Jadi5c61a952012-05-04 17:05:35 -0700340 target_detect(&board);
341 target_baseband_detect(&board);
Shashank Mittala635abf2012-03-28 18:11:43 -0700342}
343
Amol Jadi5c61a952012-05-04 17:05:35 -0700344uint32_t board_platform_id(void)
Shashank Mittala635abf2012-03-28 18:11:43 -0700345{
346 return board.platform;
347}
348
Amol Jadi5c61a952012-05-04 17:05:35 -0700349uint32_t board_target_id()
Shashank Mittala635abf2012-03-28 18:11:43 -0700350{
351 return board.target;
352}
353
Amol Jadi5c61a952012-05-04 17:05:35 -0700354uint32_t board_baseband()
Shashank Mittala635abf2012-03-28 18:11:43 -0700355{
356 return board.baseband;
357}
Neeti Desai465491e2012-07-31 12:53:35 -0700358
359uint32_t board_hardware_id()
360{
361 return board.platform_hw;
362}
Deepa Dinamanib8b16432012-08-24 15:48:45 -0700363
Joel Kingaa335dc2013-06-03 16:11:08 -0700364uint32_t board_hardware_subtype(void)
365{
366 return board.platform_subtype;
367}
368
Sundarajan Srinivasan763c0db2014-05-20 17:08:36 -0700369uint32_t board_foundry_id(void)
370{
371 return board.foundry_id;
372}
373
Sridhar Parasuramc5f035f2014-10-22 12:37:36 -0700374uint32_t board_chip_serial(void)
375{
376 return board.chip_serial;
377}
378
Channagoud Kadabibc0e47e2013-02-15 19:41:21 -0800379uint8_t board_pmic_info(struct board_pmic_data *info, uint8_t num_ent)
Deepa Dinamanib8b16432012-08-24 15:48:45 -0700380{
Channagoud Kadabibc0e47e2013-02-15 19:41:21 -0800381 uint8_t i;
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700382 if (format_major == 0x0)
383 {
384 if (format_minor < 0xB)
385 {
386 for (i = 0; i < num_ent && i < SMEM_MAX_PMIC_DEVICES; i++) {
387 info->pmic_type = board.pmic_info[i].pmic_type;
388 info->pmic_version = board.pmic_info[i].pmic_version;
389 info->pmic_target = board.pmic_info[i].pmic_target;
390 info++;
391 }
392 return (i--);
393 }
Channagoud Kadabibc0e47e2013-02-15 19:41:21 -0800394 }
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700395 return 0;
Deepa Dinamanib8b16432012-08-24 15:48:45 -0700396}
Channagoud Kadabiafd62bf2013-01-08 20:32:52 -0800397
Channagoud Kadabi062d4832015-09-18 14:22:35 -0700398bool board_pmic_type(uint32_t type)
399{
400 uint8_t i;
401 if (format_major == 0x0 && format_minor >= 0x0B)
402 {
403 for (i = 0; i < SMEM_MAX_PMIC_DEVICES; i++)
404 {
405 if (type == (board.pmic_info_array[i].pmic_type & 0x0000ffff))
406 return true;
407 }
408 }
409
410 return false;
411}
412
Parth Dixit353a8792015-10-20 01:49:37 +0530413void board_pmi_target_set(uint8_t num_ent,uint8_t rev)
414{
415 if (format_major == 0x0 && num_ent < SMEM_MAX_PMIC_DEVICES)
416 {
417 if (format_minor < 0xB && num_ent < SMEM_V8_SMEM_MAX_PMIC_DEVICES)
418 {
419 board.pmic_info[num_ent].pmic_target &= 0xffffff00;
420 board.pmic_info[num_ent].pmic_target |= rev;
421 }
422 else
423 {
424 if (num_ent < board.num_pmics)
425 {
426 board.pmic_info_array[num_ent].pmic_target &= 0xffffff00;
427 board.pmic_info_array[num_ent].pmic_target |= rev;
428 }
429 }
430 }
431}
432
Lijuan Gao9f152862014-08-18 13:45:24 +0800433uint32_t board_pmic_target(uint8_t num_ent)
434{
Sridhar Parasuram701c8302015-06-15 11:03:14 -0700435 if (format_major == 0x0 && num_ent < SMEM_MAX_PMIC_DEVICES)
436 {
437 if (format_minor < 0xB && num_ent < SMEM_V8_SMEM_MAX_PMIC_DEVICES)
438 {
439 return board.pmic_info[num_ent].pmic_target;
440 }
441 else
442 {
443 if (num_ent < board.num_pmics)
444 return board.pmic_info_array[num_ent].pmic_target;
445 }
Lijuan Gao9f152862014-08-18 13:45:24 +0800446 }
447 return 0;
448}
449
Channagoud Kadabiafd62bf2013-01-08 20:32:52 -0800450uint32_t board_soc_version()
451{
452 return board.platform_version;
453}
Aparna Mallavarapu6eb30902014-05-13 17:03:10 +0530454
455uint32_t board_get_ddr_subtype(void)
456{
457 ram_partition ptn_entry;
458 unsigned int index;
459 uint32_t ret = 0;
460 uint32_t len = 0;
461 unsigned ddr_size = 0;
462
Aparna Mallavarapub377b792014-06-24 19:56:03 +0530463 /* Make sure RAM partition table is initialized */
464 ASSERT(smem_ram_ptable_init_v1());
465
Aparna Mallavarapu6eb30902014-05-13 17:03:10 +0530466 len = smem_get_ram_ptable_len();
467
468 /* Calculating the size of the mem_info_ptr */
469 for (index = 0 ; index < len; index++)
470 {
471 smem_get_ram_ptable_entry(&ptn_entry, index);
472
473 if((ptn_entry.category == SDRAM) &&
474 (ptn_entry.type == SYS_MEMORY))
475 {
476 ddr_size += ptn_entry.size;
477 }
478 }
479
480 switch(ddr_size)
481 {
482 case DDR_512MB:
483 ret = SUBTYPE_512MB;
484 break;
485 default:
486 ret = 0;
487 break;
488 };
489
490 return ret;
491}
492
493uint32_t board_hlos_subtype(void)
494{
495 return board.platform_hlos_subtype;
496}
Channagoud Kadabi8fb2ab52015-06-02 16:19:24 -0700497
498void board_update_boot_dev(uint32_t boot_dev)
499{
500 /* HLOS subtype
501 * bit no |31 20 | 19 16|15 13 |12 11 | 10 8 | 7 0|
502 * board.platform_hlos_subtype = |reserved | Boot device |Reserved | Panel | DDR detection | subtype|
503 * | bits | | bits | Detection |
504 */
505 board.platform_hlos_subtype |= (boot_dev << 16);
506}