2018-04-04 14:29:46 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
|
|
*
|
2018-05-26 01:49:13 +08:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2018-04-04 14:29:46 +08:00
|
|
|
*/
|
|
|
|
|
2018-05-22 08:30:50 +08:00
|
|
|
#include <hypervisor.h>
|
2018-04-04 14:29:46 +08:00
|
|
|
|
|
|
|
/* The table includes cpu px info of Intel A3960 SoC */
|
2018-06-13 16:31:29 +08:00
|
|
|
static const struct cpu_px_data px_a3960[] = {
|
2018-07-06 13:49:41 +08:00
|
|
|
{0x960UL, 0UL, 0xAUL, 0xAUL, 0x1800UL, 0x1800UL}, /* P0 */
|
|
|
|
{0x8FCUL, 0UL, 0xAUL, 0xAUL, 0x1700UL, 0x1700UL}, /* P1 */
|
|
|
|
{0x898UL, 0UL, 0xAUL, 0xAUL, 0x1600UL, 0x1600UL}, /* P2 */
|
|
|
|
{0x834UL, 0UL, 0xAUL, 0xAUL, 0x1500UL, 0x1500UL}, /* P3 */
|
|
|
|
{0x7D0UL, 0UL, 0xAUL, 0xAUL, 0x1400UL, 0x1400UL}, /* P4 */
|
|
|
|
{0x76CUL, 0UL, 0xAUL, 0xAUL, 0x1300UL, 0x1300UL}, /* P5 */
|
|
|
|
{0x708UL, 0UL, 0xAUL, 0xAUL, 0x1200UL, 0x1200UL}, /* P6 */
|
|
|
|
{0x6A4UL, 0UL, 0xAUL, 0xAUL, 0x1100UL, 0x1100UL}, /* P7 */
|
|
|
|
{0x640UL, 0UL, 0xAUL, 0xAUL, 0x1000UL, 0x1000UL}, /* P8 */
|
|
|
|
{0x5DCUL, 0UL, 0xAUL, 0xAUL, 0x0F00UL, 0x0F00UL}, /* P9 */
|
|
|
|
{0x578UL, 0UL, 0xAUL, 0xAUL, 0x0E00UL, 0x0E00UL}, /* P10 */
|
|
|
|
{0x514UL, 0UL, 0xAUL, 0xAUL, 0x0D00UL, 0x0D00UL}, /* P11 */
|
|
|
|
{0x4B0UL, 0UL, 0xAUL, 0xAUL, 0x0C00UL, 0x0C00UL}, /* P12 */
|
|
|
|
{0x44CUL, 0UL, 0xAUL, 0xAUL, 0x0B00UL, 0x0B00UL}, /* P13 */
|
|
|
|
{0x3E8UL, 0UL, 0xAUL, 0xAUL, 0x0A00UL, 0x0A00UL}, /* P14 */
|
|
|
|
{0x384UL, 0UL, 0xAUL, 0xAUL, 0x0900UL, 0x0900UL}, /* P15 */
|
|
|
|
{0x320UL, 0UL, 0xAUL, 0xAUL, 0x0800UL, 0x0800UL} /* P16 */
|
2018-04-04 14:29:46 +08:00
|
|
|
};
|
|
|
|
|
2018-04-17 13:52:00 +08:00
|
|
|
/* The table includes cpu cx info of Intel A3960 SoC */
|
2018-06-13 16:31:29 +08:00
|
|
|
static const struct cpu_cx_data cx_a3960[] = {
|
2018-07-06 13:49:41 +08:00
|
|
|
{{SPACE_FFixedHW, 0x0U, 0U, 0U, 0UL}, 0x1U, 0x1U, 0x3E8UL}, /* C1 */
|
|
|
|
{{SPACE_SYSTEM_IO, 0x8U, 0U, 0U, 0x415UL}, 0x2U, 0x32U, 0x0AUL}, /* C2 */
|
|
|
|
{{SPACE_SYSTEM_IO, 0x8U, 0U, 0U, 0x419UL}, 0x3U, 0x96U, 0x0AUL} /* C3 */
|
2018-04-17 13:52:00 +08:00
|
|
|
};
|
|
|
|
|
2018-06-08 12:26:18 +08:00
|
|
|
/* The table includes cpu px info of Intel A3950 SoC */
|
2018-06-13 16:31:29 +08:00
|
|
|
static const struct cpu_px_data px_a3950[] = {
|
2018-07-06 13:49:41 +08:00
|
|
|
{0x7D0UL, 0UL, 0xAUL, 0xAUL, 0x1400UL, 0x1400UL}, /* P0 */
|
|
|
|
{0x76CUL, 0UL, 0xAUL, 0xAUL, 0x1300UL, 0x1300UL}, /* P1 */
|
|
|
|
{0x708UL, 0UL, 0xAUL, 0xAUL, 0x1200UL, 0x1200UL}, /* P2 */
|
|
|
|
{0x6A4UL, 0UL, 0xAUL, 0xAUL, 0x1100UL, 0x1100UL}, /* P3 */
|
|
|
|
{0x640UL, 0UL, 0xAUL, 0xAUL, 0x1000UL, 0x1000UL}, /* P4 */
|
|
|
|
{0x5DCUL, 0UL, 0xAUL, 0xAUL, 0x0F00UL, 0x0F00UL}, /* P5 */
|
|
|
|
{0x578UL, 0UL, 0xAUL, 0xAUL, 0x0E00UL, 0x0E00UL}, /* P6 */
|
|
|
|
{0x514UL, 0UL, 0xAUL, 0xAUL, 0x0D00UL, 0x0D00UL}, /* P7 */
|
|
|
|
{0x4B0UL, 0UL, 0xAUL, 0xAUL, 0x0C00UL, 0x0C00UL}, /* P8 */
|
|
|
|
{0x44CUL, 0UL, 0xAUL, 0xAUL, 0x0B00UL, 0x0B00UL}, /* P9 */
|
|
|
|
{0x3E8UL, 0UL, 0xAUL, 0xAUL, 0x0A00UL, 0x0A00UL}, /* P10 */
|
|
|
|
{0x384UL, 0UL, 0xAUL, 0xAUL, 0x0900UL, 0x0900UL}, /* P11 */
|
|
|
|
{0x320UL, 0UL, 0xAUL, 0xAUL, 0x0800UL, 0x0800UL} /* P12 */
|
2018-06-08 12:26:18 +08:00
|
|
|
};
|
|
|
|
|
2018-04-07 17:14:58 +08:00
|
|
|
/* The table includes cpu px info of Intel J3455 SoC */
|
2018-06-13 16:31:29 +08:00
|
|
|
static const struct cpu_px_data px_j3455[] = {
|
2018-07-06 13:49:41 +08:00
|
|
|
{0x5DDUL, 0UL, 0xAUL, 0xAUL, 0x1700UL, 0x1700UL}, /* P0 */
|
|
|
|
{0x5DCUL, 0UL, 0xAUL, 0xAUL, 0x0F00UL, 0x0F00UL}, /* P1 */
|
|
|
|
{0x578UL, 0UL, 0xAUL, 0xAUL, 0x0E00UL, 0x0E00UL}, /* P2 */
|
|
|
|
{0x514UL, 0UL, 0xAUL, 0xAUL, 0x0D00UL, 0x0D00UL}, /* P3 */
|
|
|
|
{0x4B0UL, 0UL, 0xAUL, 0xAUL, 0x0C00UL, 0x0C00UL}, /* P4 */
|
|
|
|
{0x44CUL, 0UL, 0xAUL, 0xAUL, 0x0B00UL, 0x0B00UL}, /* P5 */
|
|
|
|
{0x3E8UL, 0UL, 0xAUL, 0xAUL, 0x0A00UL, 0x0A00UL}, /* P6 */
|
|
|
|
{0x384UL, 0UL, 0xAUL, 0xAUL, 0x0900UL, 0x0900UL}, /* P7 */
|
|
|
|
{0x320UL, 0UL, 0xAUL, 0xAUL, 0x0800UL, 0x0800UL} /* P8 */
|
2018-04-07 17:14:58 +08:00
|
|
|
};
|
|
|
|
|
2018-04-27 12:08:39 +08:00
|
|
|
/* The table includes cpu cx info of Intel J3455 SoC */
|
2018-06-13 16:31:29 +08:00
|
|
|
static const struct cpu_cx_data cx_j3455[] = {
|
2018-07-06 13:49:41 +08:00
|
|
|
{{SPACE_FFixedHW, 0x1U, 0x2U, 0x1U, 0x01UL}, 0x1U, 0x1U, 0x3E8UL}, /* C1 */
|
|
|
|
{{SPACE_FFixedHW, 0x1U, 0x2U, 0x1U, 0x21UL}, 0x2U, 0x32U, 0x0AUL}, /* C2 */
|
|
|
|
{{SPACE_FFixedHW, 0x1U, 0x2U, 0x1U, 0x60UL}, 0x3U, 0x96U, 0x0AUL} /* C3 */
|
2018-04-27 12:08:39 +08:00
|
|
|
};
|
|
|
|
|
2018-06-13 16:31:29 +08:00
|
|
|
static const struct cpu_state_table {
|
2018-04-17 12:12:33 +08:00
|
|
|
char model_name[64];
|
|
|
|
struct cpu_state_info state_info;
|
|
|
|
} cpu_state_tbl[] = {
|
|
|
|
{"Intel(R) Atom(TM) Processor A3960 @ 1.90GHz",
|
2018-07-24 11:28:46 +08:00
|
|
|
{(uint8_t)ARRAY_SIZE(px_a3960), px_a3960,
|
|
|
|
(uint8_t)ARRAY_SIZE(cx_a3960), cx_a3960}
|
2018-04-17 12:12:33 +08:00
|
|
|
},
|
2018-06-08 12:26:18 +08:00
|
|
|
{"Intel(R) Atom(TM) Processor A3950 @ 1.60GHz",
|
2018-07-24 11:28:46 +08:00
|
|
|
{(uint8_t)ARRAY_SIZE(px_a3950), px_a3950,
|
|
|
|
(uint8_t)ARRAY_SIZE(cx_a3960), cx_a3960} /* Cx is same as A3960 */
|
2018-06-08 12:26:18 +08:00
|
|
|
},
|
2018-04-17 12:12:33 +08:00
|
|
|
{"Intel(R) Celeron(R) CPU J3455 @ 1.50GHz",
|
2018-07-24 11:28:46 +08:00
|
|
|
{(uint8_t)ARRAY_SIZE(px_j3455), px_j3455,
|
|
|
|
(uint8_t)ARRAY_SIZE(cx_j3455), cx_j3455}
|
2018-04-17 12:12:33 +08:00
|
|
|
}
|
2018-04-04 14:29:46 +08:00
|
|
|
};
|
|
|
|
|
2018-08-11 03:59:58 +08:00
|
|
|
static int get_state_tbl_idx(const char *cpuname)
|
2018-04-04 14:29:46 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int count = ARRAY_SIZE(cpu_state_tbl);
|
|
|
|
|
2018-06-20 13:32:59 +08:00
|
|
|
if (cpuname == NULL) {
|
2018-04-04 14:29:46 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
2018-06-20 13:32:59 +08:00
|
|
|
if (strcmp((cpu_state_tbl[i].model_name),
|
|
|
|
cpuname) == 0) {
|
2018-04-04 14:29:46 +08:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void load_cpu_state_data(void)
|
|
|
|
{
|
|
|
|
int tbl_idx;
|
2018-06-13 16:31:29 +08:00
|
|
|
const struct cpu_state_info *state_info;
|
2018-04-04 14:29:46 +08:00
|
|
|
|
2018-07-06 13:49:41 +08:00
|
|
|
(void)memset(&boot_cpu_data.state_info, 0U,
|
2018-04-17 12:12:33 +08:00
|
|
|
sizeof(struct cpu_state_info));
|
2018-04-04 14:29:46 +08:00
|
|
|
|
|
|
|
tbl_idx = get_state_tbl_idx(boot_cpu_data.model_name);
|
|
|
|
if (tbl_idx < 0) {
|
|
|
|
/* The state table is not found. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-17 12:12:33 +08:00
|
|
|
state_info = &(cpu_state_tbl + tbl_idx)->state_info;
|
2018-04-05 19:08:38 +08:00
|
|
|
|
2018-06-20 13:32:59 +08:00
|
|
|
if ((state_info->px_cnt != 0U) && (state_info->px_data != NULL)) {
|
2018-04-17 12:12:33 +08:00
|
|
|
if (state_info->px_cnt > MAX_PSTATE) {
|
|
|
|
boot_cpu_data.state_info.px_cnt = MAX_PSTATE;
|
|
|
|
} else {
|
|
|
|
boot_cpu_data.state_info.px_cnt = state_info->px_cnt;
|
2018-04-05 19:08:38 +08:00
|
|
|
}
|
|
|
|
|
2018-04-17 12:12:33 +08:00
|
|
|
boot_cpu_data.state_info.px_data = state_info->px_data;
|
2018-04-05 19:58:40 +08:00
|
|
|
}
|
2018-04-17 13:52:00 +08:00
|
|
|
|
2018-06-20 13:32:59 +08:00
|
|
|
if ((state_info->cx_cnt != 0U) && (state_info->cx_data != NULL)) {
|
2018-04-17 13:52:00 +08:00
|
|
|
if (state_info->cx_cnt > MAX_CX_ENTRY) {
|
|
|
|
boot_cpu_data.state_info.cx_cnt = MAX_CX_ENTRY;
|
|
|
|
} else {
|
|
|
|
boot_cpu_data.state_info.cx_cnt = state_info->cx_cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
boot_cpu_data.state_info.cx_data = state_info->cx_data;
|
|
|
|
}
|
|
|
|
|
2018-04-05 19:58:40 +08:00
|
|
|
}
|