vijay kumar | 27c6aab | 2015-12-11 16:23:25 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 2 | * |
| 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 Kadabi | afd62bf | 2013-01-08 20:32:52 -0800 | [diff] [blame] | 12 | * * Neither the name of The Linux Foundation, Inc. nor the names of its |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 13 | * 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 Parasuram | f2348af | 2014-11-18 16:16:57 -0800 | [diff] [blame] | 34 | #include <boot_device.h> |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 35 | |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 36 | static uint16_t format_major = 0; |
| 37 | static uint16_t format_minor = 0; |
| 38 | |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 39 | static struct board_data board = {UNKNOWN, |
Channagoud Kadabi | bc0e47e | 2013-02-15 19:41:21 -0800 | [diff] [blame] | 40 | 0, |
Sundarajan Srinivasan | 763c0db | 2014-05-20 17:08:36 -0700 | [diff] [blame] | 41 | 0, |
Sridhar Parasuram | c5f035f | 2014-10-22 12:37:36 -0700 | [diff] [blame] | 42 | 0, |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 43 | HW_PLATFORM_UNKNOWN, |
| 44 | HW_PLATFORM_SUBTYPE_UNKNOWN, |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame] | 45 | LINUX_MACHTYPE_UNKNOWN, |
Deepa Dinamani | b8b1643 | 2012-08-24 15:48:45 -0700 | [diff] [blame] | 46 | BASEBAND_MSM, |
Veera Sundaram Sankaran | 0018151 | 2014-12-09 11:23:39 -0800 | [diff] [blame] | 47 | {{PMIC_IS_INVALID, 0, 0}, {PMIC_IS_INVALID, 0, 0}, |
| 48 | {PMIC_IS_INVALID, 0, 0}}, |
vijay kumar | 4f4405f | 2014-08-08 11:49:53 +0530 | [diff] [blame] | 49 | 0, |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 50 | 0, |
| 51 | 0, |
| 52 | NULL, |
Channagoud Kadabi | bc0e47e | 2013-02-15 19:41:21 -0800 | [diff] [blame] | 53 | }; |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 54 | |
| 55 | static void platform_detect() |
| 56 | { |
| 57 | struct smem_board_info_v6 board_info_v6; |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 58 | struct smem_board_info_v7 board_info_v7; |
Channagoud Kadabi | bc0e47e | 2013-02-15 19:41:21 -0800 | [diff] [blame] | 59 | struct smem_board_info_v8 board_info_v8; |
Sridhar Parasuram | ece2805 | 2014-11-18 09:03:08 -0800 | [diff] [blame] | 60 | struct smem_board_info_v9 board_info_v9; |
| 61 | struct smem_board_info_v10 board_info_v10; |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 62 | struct smem_board_info_v11 board_info_v11; |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 63 | unsigned int board_info_len = 0; |
| 64 | unsigned ret = 0; |
| 65 | unsigned format = 0; |
Lijuan Gao | 9f15286 | 2014-08-18 13:45:24 +0800 | [diff] [blame] | 66 | unsigned pmic_type = 0; |
Channagoud Kadabi | bc0e47e | 2013-02-15 19:41:21 -0800 | [diff] [blame] | 67 | uint8_t i; |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 68 | |
| 69 | ret = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION, |
| 70 | &format, sizeof(format), 0); |
| 71 | if (ret) |
| 72 | return; |
| 73 | |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 74 | /* 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 Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 82 | { |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 83 | if (format_minor == 6) |
| 84 | { |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 85 | board_info_len = sizeof(board_info_v6); |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 86 | |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 87 | ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION, |
| 88 | &board_info_v6, |
| 89 | board_info_len); |
| 90 | if (ret) |
| 91 | return; |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 92 | |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 93 | 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 Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 101 | |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 102 | ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION, |
| 103 | &board_info_v7, |
| 104 | board_info_len); |
| 105 | if (ret) |
| 106 | return; |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 107 | |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 108 | 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 Parasuram | ece2805 | 2014-11-18 09:03:08 -0800 | [diff] [blame] | 115 | else if (format_minor == 8) |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 116 | { |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 117 | board_info_len = sizeof(board_info_v8); |
Channagoud Kadabi | bc0e47e | 2013-02-15 19:41:21 -0800 | [diff] [blame] | 118 | |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 119 | ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION, |
| 120 | &board_info_v8, |
| 121 | board_info_len); |
| 122 | if (ret) |
| 123 | return; |
Channagoud Kadabi | bc0e47e | 2013-02-15 19:41:21 -0800 | [diff] [blame] | 124 | |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 125 | 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 Yu | ca51ee2 | 2013-06-27 21:45:24 +0800 | [diff] [blame] | 129 | |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 130 | /* |
| 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 Gao | 9f15286 | 2014-08-18 13:45:24 +0800 | [diff] [blame] | 144 | |
| 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 Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 155 | } |
Sridhar Parasuram | ece2805 | 2014-11-18 09:03:08 -0800 | [diff] [blame] | 156 | } |
| 157 | else if (format_minor == 0x9) |
| 158 | { |
| 159 | board_info_len = sizeof(board_info_v9); |
Sundarajan Srinivasan | 763c0db | 2014-05-20 17:08:36 -0700 | [diff] [blame] | 160 | |
Sridhar Parasuram | ece2805 | 2014-11-18 09:03:08 -0800 | [diff] [blame] | 161 | ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION, |
| 162 | &board_info_v9, |
| 163 | board_info_len); |
| 164 | if (ret) |
| 165 | return; |
Sridhar Parasuram | c5f035f | 2014-10-22 12:37:36 -0700 | [diff] [blame] | 166 | |
Sridhar Parasuram | ece2805 | 2014-11-18 09:03:08 -0800 | [diff] [blame] | 167 | 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 Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 200 | else if (format_minor == 0xA) |
Sridhar Parasuram | ece2805 | 2014-11-18 09:03:08 -0800 | [diff] [blame] | 201 | { |
| 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 Kadabi | bc0e47e | 2013-02-15 19:41:21 -0800 | [diff] [blame] | 243 | } |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 244 | 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 Mallavarapu | 6eb3090 | 2014-05-13 17:03:10 +0530 | [diff] [blame] | 275 | |
| 276 | /* HLOS subtype |
Unnati Gandhi | 2488505 | 2014-11-27 16:57:49 +0530 | [diff] [blame] | 277 | * 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 Mallavarapu | 6eb3090 | 2014-05-13 17:03:10 +0530 | [diff] [blame] | 280 | */ |
Unnati Gandhi | 2488505 | 2014-11-27 16:57:49 +0530 | [diff] [blame] | 281 | board.platform_hlos_subtype = (board_get_ddr_subtype() << 8) | (platform_get_boot_dev() << 16) | (platform_detect_panel() << 11); |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 282 | } |
| 283 | else |
| 284 | { |
Channagoud Kadabi | 4f370b4 | 2014-05-21 16:06:59 -0700 | [diff] [blame] | 285 | dprintf(CRITICAL, "Unsupported board info format %u.%u\n", format_major, format_minor); |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 286 | ASSERT(0); |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 287 | } |
| 288 | } |
| 289 | |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 290 | void pmic_info_populate() |
| 291 | { |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 292 | uint32_t pmic_type = 0; |
vijay kumar | 27c6aab | 2015-12-11 16:23:25 +0530 | [diff] [blame] | 293 | void *smem_board_info_addr = NULL; |
| 294 | uint32_t smem_board_info_size = 0; |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 295 | |
| 296 | if (format_minor < 0xB) |
| 297 | { |
| 298 | // not needed for smem versions < 0xB |
| 299 | return; |
| 300 | } |
vijay kumar | 27c6aab | 2015-12-11 16:23:25 +0530 | [diff] [blame] | 301 | smem_board_info_addr = smem_get_alloc_entry(SMEM_BOARD_INFO_LOCATION, &smem_board_info_size); |
| 302 | if (smem_board_info_addr == NULL) |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 303 | { |
vijay kumar | 27c6aab | 2015-12-11 16:23:25 +0530 | [diff] [blame] | 304 | dprintf(CRITICAL, "Error reading the smem board info address\n"); |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 305 | ASSERT(0); |
| 306 | } |
vijay kumar | 27c6aab | 2015-12-11 16:23:25 +0530 | [diff] [blame] | 307 | |
| 308 | if (smem_board_info_size < board.pmic_array_offset) |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 309 | { |
vijay kumar | 27c6aab | 2015-12-11 16:23:25 +0530 | [diff] [blame] | 310 | dprintf(CRITICAL, "Invalid SMEM board info\n"); |
| 311 | ASSERT(0); |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 312 | } |
| 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 kumar | 27c6aab | 2015-12-11 16:23:25 +0530 | [diff] [blame] | 319 | |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 320 | struct board_pmic_data *info = board.pmic_info_array; |
| 321 | for (uint8_t i = 0; i < board.num_pmics; i++) |
| 322 | { |
vijay kumar | 27c6aab | 2015-12-11 16:23:25 +0530 | [diff] [blame] | 323 | memcpy(info, smem_board_info_addr + board.pmic_array_offset + (i * sizeof(struct smem_pmic_info)), sizeof(struct smem_pmic_info)); |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 324 | /* |
| 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 Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 335 | } |
| 336 | |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 337 | void board_init() |
| 338 | { |
| 339 | platform_detect(); |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame] | 340 | target_detect(&board); |
| 341 | target_baseband_detect(&board); |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 342 | } |
| 343 | |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame] | 344 | uint32_t board_platform_id(void) |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 345 | { |
| 346 | return board.platform; |
| 347 | } |
| 348 | |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame] | 349 | uint32_t board_target_id() |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 350 | { |
| 351 | return board.target; |
| 352 | } |
| 353 | |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame] | 354 | uint32_t board_baseband() |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 355 | { |
| 356 | return board.baseband; |
| 357 | } |
Neeti Desai | 465491e | 2012-07-31 12:53:35 -0700 | [diff] [blame] | 358 | |
| 359 | uint32_t board_hardware_id() |
| 360 | { |
| 361 | return board.platform_hw; |
| 362 | } |
Deepa Dinamani | b8b1643 | 2012-08-24 15:48:45 -0700 | [diff] [blame] | 363 | |
Joel King | aa335dc | 2013-06-03 16:11:08 -0700 | [diff] [blame] | 364 | uint32_t board_hardware_subtype(void) |
| 365 | { |
| 366 | return board.platform_subtype; |
| 367 | } |
| 368 | |
Sundarajan Srinivasan | 763c0db | 2014-05-20 17:08:36 -0700 | [diff] [blame] | 369 | uint32_t board_foundry_id(void) |
| 370 | { |
| 371 | return board.foundry_id; |
| 372 | } |
| 373 | |
Sridhar Parasuram | c5f035f | 2014-10-22 12:37:36 -0700 | [diff] [blame] | 374 | uint32_t board_chip_serial(void) |
| 375 | { |
| 376 | return board.chip_serial; |
| 377 | } |
| 378 | |
Channagoud Kadabi | bc0e47e | 2013-02-15 19:41:21 -0800 | [diff] [blame] | 379 | uint8_t board_pmic_info(struct board_pmic_data *info, uint8_t num_ent) |
Deepa Dinamani | b8b1643 | 2012-08-24 15:48:45 -0700 | [diff] [blame] | 380 | { |
Channagoud Kadabi | bc0e47e | 2013-02-15 19:41:21 -0800 | [diff] [blame] | 381 | uint8_t i; |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 382 | 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 Kadabi | bc0e47e | 2013-02-15 19:41:21 -0800 | [diff] [blame] | 394 | } |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 395 | return 0; |
Deepa Dinamani | b8b1643 | 2012-08-24 15:48:45 -0700 | [diff] [blame] | 396 | } |
Channagoud Kadabi | afd62bf | 2013-01-08 20:32:52 -0800 | [diff] [blame] | 397 | |
Channagoud Kadabi | 062d483 | 2015-09-18 14:22:35 -0700 | [diff] [blame] | 398 | bool 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 Dixit | 353a879 | 2015-10-20 01:49:37 +0530 | [diff] [blame] | 413 | void 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 Gao | 9f15286 | 2014-08-18 13:45:24 +0800 | [diff] [blame] | 433 | uint32_t board_pmic_target(uint8_t num_ent) |
| 434 | { |
Sridhar Parasuram | 701c830 | 2015-06-15 11:03:14 -0700 | [diff] [blame] | 435 | 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 Gao | 9f15286 | 2014-08-18 13:45:24 +0800 | [diff] [blame] | 446 | } |
| 447 | return 0; |
| 448 | } |
| 449 | |
Channagoud Kadabi | afd62bf | 2013-01-08 20:32:52 -0800 | [diff] [blame] | 450 | uint32_t board_soc_version() |
| 451 | { |
| 452 | return board.platform_version; |
| 453 | } |
Aparna Mallavarapu | 6eb3090 | 2014-05-13 17:03:10 +0530 | [diff] [blame] | 454 | |
| 455 | uint32_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 Mallavarapu | b377b79 | 2014-06-24 19:56:03 +0530 | [diff] [blame] | 463 | /* Make sure RAM partition table is initialized */ |
| 464 | ASSERT(smem_ram_ptable_init_v1()); |
| 465 | |
Aparna Mallavarapu | 6eb3090 | 2014-05-13 17:03:10 +0530 | [diff] [blame] | 466 | 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 | |
| 493 | uint32_t board_hlos_subtype(void) |
| 494 | { |
| 495 | return board.platform_hlos_subtype; |
| 496 | } |
Channagoud Kadabi | 8fb2ab5 | 2015-06-02 16:19:24 -0700 | [diff] [blame] | 497 | |
| 498 | void 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 | } |