|
| 1 | +/* |
| 2 | + * Copyright (C) 2018 Intel Corporation. All rights reserved. |
| 3 | + * |
| 4 | + * Redistribution and use in source and binary forms, with or without |
| 5 | + * modification, are permitted provided that the following conditions |
| 6 | + * are met: |
| 7 | + * |
| 8 | + * * Redistributions of source code must retain the above copyright |
| 9 | + * notice, this list of conditions and the following disclaimer. |
| 10 | + * * Redistributions in binary form must reproduce the above copyright |
| 11 | + * notice, this list of conditions and the following disclaimer in |
| 12 | + * the documentation and/or other materials provided with the |
| 13 | + * distribution. |
| 14 | + * * Neither the name of Intel Corporation nor the names of its |
| 15 | + * contributors may be used to endorse or promote products derived |
| 16 | + * from this software without specific prior written permission. |
| 17 | + * |
| 18 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 | + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 | + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | + */ |
| 30 | + |
| 31 | +#include <hv_lib.h> |
| 32 | +#include <cpu.h> |
| 33 | +#include <acrn_common.h> |
| 34 | +#include <cpu_state_tbl.h> |
| 35 | + |
| 36 | +/* The table includes cpu px info of Intel A3960 SoC */ |
| 37 | +struct cpu_px_data px_a3960[] = { |
| 38 | + {0x960, 0, 0xA, 0xA, 0x1800, 0x1800}, /* P0 */ |
| 39 | + {0x8FC, 0, 0xA, 0xA, 0x1700, 0x1700}, /* P1 */ |
| 40 | + {0x898, 0, 0xA, 0xA, 0x1600, 0x1600}, /* P2 */ |
| 41 | + {0x834, 0, 0xA, 0xA, 0x1500, 0x1500}, /* P3 */ |
| 42 | + {0x7D0, 0, 0xA, 0xA, 0x1400, 0x1400}, /* P4 */ |
| 43 | + {0x76C, 0, 0xA, 0xA, 0x1300, 0x1300}, /* P5 */ |
| 44 | + {0x708, 0, 0xA, 0xA, 0x1200, 0x1200}, /* P6 */ |
| 45 | + {0x6A4, 0, 0xA, 0xA, 0x1100, 0x1100}, /* P7 */ |
| 46 | + {0x640, 0, 0xA, 0xA, 0x1000, 0x1000}, /* P8 */ |
| 47 | + {0x5DC, 0, 0xA, 0xA, 0x0F00, 0x0F00}, /* P9 */ |
| 48 | + {0x578, 0, 0xA, 0xA, 0x0E00, 0x0E00}, /* P10 */ |
| 49 | + {0x514, 0, 0xA, 0xA, 0x0D00, 0x0D00}, /* P11 */ |
| 50 | + {0x4B0, 0, 0xA, 0xA, 0x0C00, 0x0C00}, /* P12 */ |
| 51 | + {0x44C, 0, 0xA, 0xA, 0x0B00, 0x0B00}, /* P13 */ |
| 52 | + {0x3E8, 0, 0xA, 0xA, 0x0A00, 0x0A00}, /* P14 */ |
| 53 | + {0x384, 0, 0xA, 0xA, 0x0900, 0x0900}, /* P15 */ |
| 54 | + {0x320, 0, 0xA, 0xA, 0x0800, 0x0800} /* P16 */ |
| 55 | +}; |
| 56 | + |
| 57 | +struct cpu_state_table cpu_state_tbl[] = { |
| 58 | + {"Intel(R) Atom(TM) Processor A3960 @ 1.90GHz", 17, px_a3960} |
| 59 | +}; |
| 60 | + |
| 61 | +static int get_state_tbl_idx(char *cpuname) |
| 62 | +{ |
| 63 | + int i; |
| 64 | + int count = ARRAY_SIZE(cpu_state_tbl); |
| 65 | + |
| 66 | + if (!cpuname) { |
| 67 | + return -1; |
| 68 | + } |
| 69 | + |
| 70 | + for (i = 0; i < count; i++) { |
| 71 | + if (!strcmp((cpu_state_tbl[i].model_name), |
| 72 | + cpuname)) { |
| 73 | + return i; |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + return -1; |
| 78 | +} |
| 79 | + |
| 80 | +void load_cpu_state_data(void) |
| 81 | +{ |
| 82 | + int tbl_idx; |
| 83 | + |
| 84 | + boot_cpu_data.px_cnt = 0; |
| 85 | + boot_cpu_data.px_data = NULL; |
| 86 | + |
| 87 | + tbl_idx = get_state_tbl_idx(boot_cpu_data.model_name); |
| 88 | + if (tbl_idx < 0) { |
| 89 | + /* The state table is not found. */ |
| 90 | + return; |
| 91 | + } |
| 92 | + |
| 93 | + if (!((cpu_state_tbl + tbl_idx)->px_cnt) |
| 94 | + || !((cpu_state_tbl + tbl_idx)->px_data)) { |
| 95 | + /* The state table must be wrong. */ |
| 96 | + return; |
| 97 | + } |
| 98 | + |
| 99 | + if ((cpu_state_tbl + tbl_idx)->px_cnt > MAX_PSTATE) { |
| 100 | + boot_cpu_data.px_cnt = MAX_PSTATE; |
| 101 | + } else { |
| 102 | + boot_cpu_data.px_cnt = (cpu_state_tbl + tbl_idx)->px_cnt; |
| 103 | + } |
| 104 | + |
| 105 | + boot_cpu_data.px_data = (cpu_state_tbl + tbl_idx)->px_data; |
| 106 | + |
| 107 | +} |
0 commit comments