Taniya Das | 6b81bcd | 2022-07-04 21:02:31 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <assert.h> |
| 4 | #include <commonlib/helpers.h> |
| 5 | #include <device/mmio.h> |
| 6 | #include <types.h> |
| 7 | #include <soc/socinfo.h> |
| 8 | #include <soc/addressmap.h> |
| 9 | |
| 10 | #define JTAG_OFFSET 0xB1014 |
| 11 | |
| 12 | static struct chipinfo chipinfolut[] = { |
Sudheer Kumar Amrabadi | 8139fc4 | 2022-10-13 08:51:22 +0530 | [diff] [blame] | 13 | /* CHIPINFO_ID_SM_KODIAK = 475 */ |
| 14 | { .jtagid = CHIPINFO_PARTNUM_SM_KODIAK, .modem = 1, .pro = 0 }, |
| 15 | /* CHIPINFO_ID_SC_KODIAK_CHROME = 487 */ |
| 16 | { .jtagid = CHIPINFO_PARTNUM_SC_KODIAK_CHROME, .modem = 1, .pro = 0 }, |
| 17 | /* CHIPINFO_ID_SC_KODIAK_WINDOWS = 488 */ |
| 18 | { .jtagid = CHIPINFO_PARTNUM_SC_KODIAK_WINDOWS, .modem = 1, .pro = 0 }, |
| 19 | /* CHIPINFO_ID_QCM_KODIAK = 497 */ |
| 20 | { .jtagid = CHIPINFO_PARTNUM_QCM_KODIAK, .modem = 1, .pro = 0 }, |
| 21 | /* CHIPINFO_ID_QCS_KODIAK = 498 */ |
| 22 | { .jtagid = CHIPINFO_PARTNUM_QCS_KODIAK, .modem = 0, .pro = 0 }, |
| 23 | /* CHIPINFO_ID_SMP_KODIAK = 499 */ |
| 24 | { .jtagid = CHIPINFO_PARTNUM_SMP_KODIAK, .modem = 0, .pro = 0 }, |
| 25 | /* CHIPINFO_ID_SM_KODIAK_LTE_ONLY = 515 */ |
| 26 | { .jtagid = CHIPINFO_PARTNUM_SM_KODIAK_LTE_ONLY, .modem = 1, .pro = 0 }, |
| 27 | /* CHIPINFO_ID_SCP_KODIAK = 546 */ |
| 28 | { .jtagid = CHIPINFO_PARTNUM_SCP_KODIAK, .modem = 0, .pro = 0 }, |
| 29 | /* CHIPINFO_ID_SC_8CGEN3 = 553 */ |
| 30 | { .jtagid = CHIPINFO_PARTNUM_SC_8CGEN3, .modem = 1, .pro = 1 }, |
| 31 | /* CHIPINFO_ID_SCP_8CGEN3 = 563 */ |
| 32 | { .jtagid = CHIPINFO_PARTNUM_SCP_8CGEN3, .modem = 0, .pro = 1 }, |
| 33 | /* CHIPINFO_ID_KODIAK_SCP_7CGEN3 = 567 */ |
| 34 | { .jtagid = CHIPINFO_PARTNUM_KODIAK_SCP_7CGEN3, .modem = 0, .pro = 0 }, |
| 35 | /* CHIPINFO_ID_QCS_KODIAK_LITE = 575 */ |
| 36 | { .jtagid = CHIPINFO_PARTNUM_QCS_KODIAK_LITE, .modem = 0, .pro = 0 }, |
| 37 | /* CHIPINFO_ID_QCM_KODIAK_LITE = 576 */ |
| 38 | { .jtagid = CHIPINFO_PARTNUM_QCM_KODIAK_LITE, .modem = 0, .pro = 0 }, |
Taniya Das | 6b81bcd | 2022-07-04 21:02:31 +0530 | [diff] [blame] | 39 | }; |
| 40 | |
Sudheer Kumar Amrabadi | 8139fc4 | 2022-10-13 08:51:22 +0530 | [diff] [blame] | 41 | static uint16_t read_jtagid(void) |
Taniya Das | 6b81bcd | 2022-07-04 21:02:31 +0530 | [diff] [blame] | 42 | { |
Sudheer Kumar Amrabadi | 8139fc4 | 2022-10-13 08:51:22 +0530 | [diff] [blame] | 43 | return (read32((void *)(TLMM_TILE_BASE + JTAG_OFFSET)) & DEVICE_ID); |
| 44 | } |
Taniya Das | 6b81bcd | 2022-07-04 21:02:31 +0530 | [diff] [blame] | 45 | |
Sudheer Kumar Amrabadi | 8139fc4 | 2022-10-13 08:51:22 +0530 | [diff] [blame] | 46 | static int match_jtagid(uint16_t jtagid) |
| 47 | { |
| 48 | int i; |
Taniya Das | 6b81bcd | 2022-07-04 21:02:31 +0530 | [diff] [blame] | 49 | |
| 50 | for (i = 0; i < ARRAY_SIZE(chipinfolut); i++) |
| 51 | if (chipinfolut[i].jtagid == jtagid) |
Sudheer Kumar Amrabadi | 8139fc4 | 2022-10-13 08:51:22 +0530 | [diff] [blame] | 52 | return i; |
Taniya Das | 6b81bcd | 2022-07-04 21:02:31 +0530 | [diff] [blame] | 53 | |
Sudheer Kumar Amrabadi | 8139fc4 | 2022-10-13 08:51:22 +0530 | [diff] [blame] | 54 | return -1; |
| 55 | } |
| 56 | |
| 57 | uint16_t socinfo_modem_supported(void) |
| 58 | { |
| 59 | uint16_t jtagid; |
| 60 | int ret; |
| 61 | |
| 62 | jtagid = read_jtagid(); |
| 63 | |
| 64 | ret = match_jtagid(jtagid); |
| 65 | if (ret != -1) |
| 66 | return chipinfolut[ret].modem; |
| 67 | |
| 68 | die("could not match jtagid\n"); |
| 69 | } |
| 70 | |
| 71 | uint16_t socinfo_pro_part(void) |
| 72 | { |
| 73 | uint16_t jtagid; |
| 74 | int ret; |
| 75 | |
| 76 | jtagid = read_jtagid(); |
| 77 | |
| 78 | ret = match_jtagid(jtagid); |
| 79 | if (ret != -1) |
| 80 | return chipinfolut[ret].pro; |
| 81 | |
| 82 | die("could not match jtagid\n"); |
| 83 | |
Taniya Das | 6b81bcd | 2022-07-04 21:02:31 +0530 | [diff] [blame] | 84 | } |