first and last commit
This commit is contained in:
commit
1bf4efd552
2612 files changed
+636500
No files matched your search
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Inc.
|
||||
*/
|
||||
|
||||
#include <platform.h>
|
||||
#include <platform/pmgr.h>
|
||||
#include <debug.h>
|
||||
|
||||
static uint64_t pmgr_binning_read_register(uint64_t address, uint32_t low, uint32_t high, bool reg64)
|
||||
{
|
||||
uint64_t result = 0;
|
||||
do {
|
||||
uint64_t current_low;
|
||||
uint64_t offset;
|
||||
uint64_t register_value;
|
||||
|
||||
if (reg64) {
|
||||
offset = high/64;
|
||||
current_low = offset * 64;
|
||||
register_value = ((uint64_t *)(address))[offset];
|
||||
} else {
|
||||
offset = high/32;
|
||||
current_low = offset * 32;
|
||||
register_value = ((uint32_t *)(address))[offset];
|
||||
}
|
||||
|
||||
// Mask useful bit : [current_low:high]
|
||||
register_value &= (1ULL << (high - current_low + 1)) - 1;
|
||||
|
||||
if (current_low <= low) {
|
||||
result |= register_value >> (low - current_low);
|
||||
break;
|
||||
}
|
||||
|
||||
result |= register_value << (current_low - low);
|
||||
high = current_low - 1;
|
||||
} while (1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint64_t pmgr_binning_read(const struct pmgr_binning_fuse_to_register *fuse_to_register, uint32_t binning_low, uint32_t binning_high)
|
||||
{
|
||||
uint32_t result = 0;
|
||||
while (1) {
|
||||
uint32_t i = 0;
|
||||
while (fuse_to_register[i].register_address != 0) {
|
||||
if ((fuse_to_register[i].binning_high >= binning_high) && (fuse_to_register[i].binning_low <= binning_high)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (fuse_to_register[i].register_address == 0) {
|
||||
return PMGR_BINNING_NOTFOUND;
|
||||
}
|
||||
|
||||
if ((fuse_to_register[i].binning_high >= binning_high) && (fuse_to_register[i].binning_low <= binning_low)) {
|
||||
result |= pmgr_binning_read_register(fuse_to_register[i].register_address,
|
||||
binning_low - fuse_to_register[i].binning_low + fuse_to_register[i].register_low,
|
||||
binning_high - fuse_to_register[i].binning_low + fuse_to_register[i].register_low,
|
||||
fuse_to_register[i].register_64bit);
|
||||
break;
|
||||
}
|
||||
result |= pmgr_binning_read_register(fuse_to_register[i].register_address,
|
||||
fuse_to_register[i].register_low,
|
||||
binning_high - fuse_to_register[i].binning_low + fuse_to_register[i].register_low,
|
||||
fuse_to_register[i].register_64bit) << (fuse_to_register[i].binning_low - binning_low);
|
||||
binning_high = fuse_to_register[i].binning_low - 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint32_t pmgr_binning_from_const_data(enum pmgr_binning_type_t type, uint32_t mode, bool use_binning)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < pmgr_binning_mode_to_const_data_size; i++) {
|
||||
if (pmgr_binning_mode_to_const_data[i].type != type) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_mode_to_const_data[i].mode != mode) {
|
||||
continue;
|
||||
}
|
||||
if ((use_binning) && pmgr_binning_mode_to_const_data[i].bingroup != pmgr_binning_get_group() && pmgr_binning_mode_to_const_data[i].bingroup != PMGR_BINNING_GROUP_ALL) {
|
||||
continue;
|
||||
}
|
||||
if ((use_binning) && (pmgr_binning_get_revision() < pmgr_binning_mode_to_const_data[i].fuse_revision_minimum)) {
|
||||
continue;
|
||||
}
|
||||
if ((!use_binning) && (pmgr_binning_mode_to_const_data[i].fuse_revision_minimum != 0)) {
|
||||
continue;
|
||||
}
|
||||
return pmgr_binning_mode_to_const_data[i].mv;
|
||||
}
|
||||
return PMGR_BINNING_NOTFOUND;
|
||||
}
|
||||
|
||||
uint32_t pmgr_binning_from_config_data(uint32_t voltage_index, const struct pmgr_binning_voltage_index_to_config **config_data)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < pmgr_binning_voltage_index_to_config_data_size; i++) {
|
||||
if (pmgr_binning_voltage_index_to_config_data[i].voltage_index != voltage_index) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_voltage_index_to_config_data[i].bingroup != pmgr_binning_get_group() && pmgr_binning_voltage_index_to_config_data[i].bingroup != PMGR_BINNING_GROUP_ALL) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_get_revision() < pmgr_binning_voltage_index_to_config_data[i].fuse_revision_minimum) {
|
||||
continue;
|
||||
}
|
||||
*config_data = &pmgr_binning_voltage_index_to_config_data[i];
|
||||
|
||||
return pmgr_binning_voltage_index_to_config_data[i].safe_voltage;
|
||||
}
|
||||
return PMGR_BINNING_NOTFOUND;
|
||||
}
|
||||
|
||||
int32_t pmgr_binning_get_voltage_offset(uint32_t voltage_index, enum pmgr_binning_type_t type)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t size = 0;
|
||||
const struct pmgr_binning_voltage_index_to_offset *voltage_index_to_offset;
|
||||
uint32_t board_id = platform_get_board_id();
|
||||
|
||||
for (i = 0; i < pmgr_binning_board_id_to_offsets_data_size; i++) {
|
||||
if (pmgr_binning_board_id_to_offsets_data[i].board_id != board_id) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_board_id_to_offsets_data[i].type != type) {
|
||||
continue;
|
||||
}
|
||||
if (platform_get_chip_revision() < pmgr_binning_board_id_to_offsets_data[i].chip_rev_min) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_board_id_to_offsets_data[i].bingroup != pmgr_binning_get_group() && pmgr_binning_board_id_to_offsets_data[i].bingroup != PMGR_BINNING_GROUP_ALL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
voltage_index_to_offset = pmgr_binning_board_id_to_offsets_data[i].voltage_offsets;
|
||||
size = pmgr_binning_board_id_to_offsets_data[i].size;
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
if (voltage_index_to_offset[i].voltage_index != voltage_index) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_get_revision() < voltage_index_to_offset[i].fuse_revision_minimum) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return voltage_index_to_offset[i].offset;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t pmgr_binning_mode_get_value(enum pmgr_binning_type_t type, uint32_t mode)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
do {
|
||||
if (pmgr_binning_mode_to_fuse_data[i].type == PMGR_BINNING_END_OF_LIST) {
|
||||
return PMGR_BINNING_NOTFOUND;
|
||||
}
|
||||
if (pmgr_binning_mode_to_fuse_data[i].type != type) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_mode_to_fuse_data[i].mode != mode) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (type != PMGR_BINNING_GROUP && pmgr_binning_mode_to_fuse_data[i].bingroup != pmgr_binning_get_group() && pmgr_binning_mode_to_fuse_data[i].bingroup != PMGR_BINNING_GROUP_ALL) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
} while (1);
|
||||
|
||||
if (pmgr_binning_mode_to_fuse_data[i].low > pmgr_binning_mode_to_fuse_data[i].high) {
|
||||
panic("Invalid low (%u) and high (%u) mode_to_fuse_data for type %u mode %u\n", pmgr_binning_mode_to_fuse_data[i].low, pmgr_binning_mode_to_fuse_data[i].high, type, mode);
|
||||
}
|
||||
|
||||
uint32_t result = pmgr_binning_read(pmgr_binning_mode_to_fuse_data[i].fuse_to_register, pmgr_binning_mode_to_fuse_data[i].low, pmgr_binning_mode_to_fuse_data[i].high);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t pmgr_binning_get_base(void)
|
||||
{
|
||||
static uint32_t base = 0;
|
||||
if (base == 0) {
|
||||
base = pmgr_binning_mode_get_value(PMGR_BINNING_BASE, 0);
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
uint32_t pmgr_binning_get_group(void)
|
||||
{
|
||||
static uint32_t group = 0;
|
||||
if (group == 0) {
|
||||
group =pmgr_binning_mode_get_value(PMGR_BINNING_GROUP, 0);
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
uint32_t pmgr_binning_get_revision(void)
|
||||
{
|
||||
static uint32_t revision = 0;
|
||||
if (revision == 0) {
|
||||
revision = pmgr_binning_mode_get_value(PMGR_BINNING_REV, 0);
|
||||
}
|
||||
return revision;
|
||||
}
|
||||
|
||||
uint32_t pmgr_binning_mode_get_mv(enum pmgr_binning_type_t type, uint32_t mode)
|
||||
{
|
||||
uint32_t value = pmgr_binning_mode_get_value(type, mode);
|
||||
if ((value == PMGR_BINNING_NOTFOUND) || (value == 0)) {
|
||||
return PMGR_BINNING_NOTFOUND;
|
||||
}
|
||||
return 25 * (pmgr_binning_get_base() + 1) + value * 5;
|
||||
}
|
||||
|
||||
uint32_t pmgr_binning_get_mv(uint32_t voltage_index, bool sram, bool use_binning)
|
||||
{
|
||||
uint32_t voltage;
|
||||
int32_t voltage_offset;
|
||||
uint32_t mode;
|
||||
enum pmgr_binning_type_t type;
|
||||
|
||||
if (sram) {
|
||||
if (voltage_index >= pmgr_binning_voltage_config_sram_data_size) {
|
||||
return PMGR_BINNING_NOTFOUND;
|
||||
}
|
||||
const struct pmgr_binning_voltage_config *binning_voltage_config;
|
||||
binning_voltage_config = &pmgr_binning_voltage_config_sram_data[voltage_index];
|
||||
|
||||
voltage = binning_voltage_config->safe_voltage;
|
||||
type = binning_voltage_config->type;
|
||||
mode = binning_voltage_config->mode;
|
||||
|
||||
if ((voltage == 0) && (type != PMGR_BINNING_NONE)){
|
||||
return pmgr_binning_from_const_data(type, mode, use_binning);
|
||||
}
|
||||
} else {
|
||||
const struct pmgr_binning_voltage_index_to_config *config_data;
|
||||
if (pmgr_binning_from_config_data(voltage_index, &config_data) == PMGR_BINNING_NOTFOUND) {
|
||||
return PMGR_BINNING_NOTFOUND;
|
||||
}
|
||||
|
||||
voltage = config_data->safe_voltage;
|
||||
type = config_data->type;
|
||||
mode = config_data->mode;
|
||||
|
||||
if (use_binning) {
|
||||
uint32_t voltage_binning = pmgr_binning_mode_get_mv(type, mode);
|
||||
if (voltage_binning != PMGR_BINNING_NOTFOUND) {
|
||||
voltage = voltage_binning;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
voltage_offset = pmgr_binning_get_voltage_offset(voltage_index, type);
|
||||
if ((int32_t)voltage + voltage_offset < 0) {
|
||||
panic("Invalid voltage offset");
|
||||
}
|
||||
|
||||
return voltage + voltage_offset;
|
||||
}
|
||||
|
||||
const struct pmgr_binning_vol_adj *pmgr_binning_get_vol_adj(uint32_t chipdid, uint32_t chip_rev, uint32_t voltage_index)
|
||||
{
|
||||
uint32_t fuse_rev = pmgr_binning_get_revision();
|
||||
|
||||
for (size_t i = 0; i < pmgr_binning_voltadj_entry_data_size; i++) {
|
||||
if (voltage_index != pmgr_binning_voltadj_entry_data[i].voltage_index) {
|
||||
continue;
|
||||
}
|
||||
if ((chip_rev < pmgr_binning_voltadj_entry_data[i].chip_rev_min)) {
|
||||
continue;
|
||||
}
|
||||
if ((fuse_rev < pmgr_binning_voltadj_entry_data[i].fuse_rev_min)) {
|
||||
continue;
|
||||
}
|
||||
return &pmgr_binning_voltadj_entry_data[i].voltages;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
/*
|
||||
|
||||
* Copyright (c) 2015 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Inc.
|
||||
*/
|
||||
|
||||
#if !RELEASE_BUILD && WITH_MENU
|
||||
|
||||
#include <sys/menu.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
#include <platform.h>
|
||||
#include <stdio.h>
|
||||
#include <sys.h>
|
||||
#include <lib/env.h>
|
||||
#include <platform/pmgr.h>
|
||||
|
||||
static bool pmgr_binning_menu_override_get_voltage_indexes(bool gpu, uint32_t *voltage_indexes, uint32_t voltage_index_size, uint32_t *voltage_index_found)
|
||||
{
|
||||
uint32_t freq = 0;
|
||||
uint32_t i = 0;
|
||||
const char *name = env_get(gpu?"pmgr_gpu_override":"pmgr_cpu_override");
|
||||
const struct pmgr_binning_voltage_index_to_config *config_data;
|
||||
*voltage_index_found = 0;
|
||||
if (name == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (i < voltage_index_size) {
|
||||
if (i > 0) {
|
||||
name = strchr(name, ',');
|
||||
if (name == NULL) {
|
||||
break;
|
||||
}
|
||||
name++;
|
||||
}
|
||||
|
||||
voltage_indexes[i] = atoi(name);
|
||||
if (pmgr_binning_from_config_data(voltage_indexes[i], &config_data) == PMGR_BINNING_NOTFOUND) {
|
||||
return false;
|
||||
}
|
||||
if ((gpu) && (config_data->type != PMGR_BINNING_GPU)) {
|
||||
return false;
|
||||
}
|
||||
if ((!gpu) && (config_data->type != PMGR_BINNING_CPU)) {
|
||||
return false;
|
||||
}
|
||||
freq = pmgr_platform_get_freq(gpu, voltage_indexes[i]);
|
||||
if (freq == 0) {
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
*voltage_index_found = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool pmgr_binning_menu_find_safe_voltage(enum pmgr_binning_type_t type, uint32_t mode,
|
||||
uint32_t *safe_voltage, uint32_t *freq)
|
||||
{
|
||||
uint32_t i;
|
||||
*freq = 0;
|
||||
for (i = 0; i < pmgr_binning_voltage_config_sram_data_size; i++) {
|
||||
if (pmgr_binning_voltage_config_sram_data[i].mode != mode) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_voltage_config_sram_data[i].type != type) {
|
||||
continue;
|
||||
}
|
||||
*safe_voltage = pmgr_binning_voltage_config_sram_data[i].safe_voltage;
|
||||
return true;
|
||||
}
|
||||
for (i = 0; i < pmgr_binning_voltage_index_to_config_data_size; i++) {
|
||||
if (pmgr_binning_voltage_index_to_config_data[i].mode != mode) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_voltage_index_to_config_data[i].type != type) {
|
||||
continue;
|
||||
}
|
||||
if (type == PMGR_BINNING_CPU) {
|
||||
*freq = pmgr_platform_get_freq(false, pmgr_binning_voltage_index_to_config_data[i].voltage_index);
|
||||
} else if (type == PMGR_BINNING_GPU) {
|
||||
*freq = pmgr_platform_get_freq(true, pmgr_binning_voltage_index_to_config_data[i].voltage_index);
|
||||
}
|
||||
*safe_voltage = pmgr_binning_voltage_index_to_config_data[i].safe_voltage;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void pmgr_binning_menu_print_type(enum pmgr_binning_type_t type)
|
||||
{
|
||||
uint32_t mode;
|
||||
for (mode = 1; mode < 63; mode++) {
|
||||
uint32_t result = pmgr_binning_mode_get_value(type, mode);
|
||||
uint32_t safe_voltage;
|
||||
uint32_t freq;
|
||||
if ((result == PMGR_BINNING_NOTFOUND) || (result == 0)) {
|
||||
continue;
|
||||
}
|
||||
printf(" mode %u %u mV (0x%x)", mode, pmgr_binning_mode_get_mv(type, mode), pmgr_binning_mode_get_value(type, mode));
|
||||
|
||||
if (!pmgr_binning_menu_find_safe_voltage(type, mode, &safe_voltage, &freq)) {
|
||||
printf(" no safe voltage");
|
||||
} else {
|
||||
printf(" safe voltage %u mV", safe_voltage);
|
||||
}
|
||||
|
||||
if (freq > 0) {
|
||||
printf(" %u MHz", freq);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void pmgr_binning_menu_voltage_config_print(const struct pmgr_binning_voltage_config *voltage_config, uint32_t voltage_index)
|
||||
{
|
||||
const char *name = "";
|
||||
uint32_t freq = 0, safe_voltage = 0, mode = 0, type = 0;
|
||||
bool sram = false;
|
||||
|
||||
if (voltage_config != NULL) {
|
||||
safe_voltage = voltage_config->safe_voltage;
|
||||
mode = voltage_config->mode;
|
||||
type = voltage_config->type;
|
||||
}
|
||||
else {
|
||||
const struct pmgr_binning_voltage_index_to_config *config_data;
|
||||
if (pmgr_binning_from_config_data(voltage_index, &config_data) == PMGR_BINNING_NOTFOUND) {
|
||||
return;
|
||||
}
|
||||
safe_voltage = config_data->safe_voltage;
|
||||
mode = config_data->mode;
|
||||
type = config_data->type;
|
||||
}
|
||||
if (type == PMGR_BINNING_NONE) {
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case PMGR_BINNING_CPU:
|
||||
name = "CPU";
|
||||
freq = pmgr_platform_get_freq(false, voltage_index);
|
||||
break;
|
||||
case PMGR_BINNING_GPU:
|
||||
name = "GPU";
|
||||
freq = pmgr_platform_get_freq(true, voltage_index);
|
||||
break;
|
||||
case PMGR_BINNING_SOC:
|
||||
name = "SOC";
|
||||
break;
|
||||
case PMGR_BINNING_CPU_SRAM:
|
||||
name = "CPU SRAM";
|
||||
sram = true;
|
||||
break;
|
||||
case PMGR_BINNING_GPU_SRAM:
|
||||
name = "GPU SRAM";
|
||||
sram = true;
|
||||
break;
|
||||
case PMGR_BINNING_SRAM:
|
||||
name = "SRAM";
|
||||
sram = true;
|
||||
break;
|
||||
default:
|
||||
name = "Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
printf(" %s index %u safe voltage %u mV",
|
||||
name,
|
||||
voltage_index,
|
||||
pmgr_binning_get_mv(voltage_index, sram, false));
|
||||
|
||||
if (pmgr_binning_mode_get_mv(type, mode) != PMGR_BINNING_NOTFOUND) {
|
||||
printf(" binning %u mV", pmgr_binning_get_mv(voltage_index, sram, true));
|
||||
} else {
|
||||
printf(" no binning %u mV", pmgr_binning_get_mv(voltage_index, sram, true));
|
||||
}
|
||||
|
||||
printf(" offset %d mV", pmgr_binning_get_voltage_offset(voltage_index, type));
|
||||
|
||||
if (mode != PMGR_BINNING_MODE_NONE && mode > 0) {
|
||||
printf(" mode %u", mode);
|
||||
}
|
||||
|
||||
if (freq > 0) {
|
||||
printf(" %u MHz", freq);
|
||||
}
|
||||
|
||||
if (sram && safe_voltage == 0) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < pmgr_binning_mode_to_const_data_size; i++) {
|
||||
if (pmgr_binning_mode_to_const_data[i].type != type) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_mode_to_const_data[i].mode != mode) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_mode_to_const_data[i].bingroup != pmgr_binning_get_group() && pmgr_binning_mode_to_const_data[i].bingroup != PMGR_BINNING_GROUP_ALL) {
|
||||
continue;
|
||||
}
|
||||
printf(" fuse >= %d %d mV", pmgr_binning_mode_to_const_data[i].fuse_revision_minimum, pmgr_binning_mode_to_const_data[i].mv + pmgr_binning_get_voltage_offset(voltage_index, type));
|
||||
}
|
||||
}
|
||||
else if (!sram && mode != PMGR_BINNING_MODE_NONE) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < pmgr_binning_voltage_index_to_config_data_size; i++) {
|
||||
if (pmgr_binning_voltage_index_to_config_data[i].voltage_index != voltage_index) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_voltage_index_to_config_data[i].type != type) {
|
||||
continue;
|
||||
}
|
||||
if (pmgr_binning_voltage_index_to_config_data[i].bingroup != pmgr_binning_get_group() && pmgr_binning_voltage_index_to_config_data[i].bingroup != PMGR_BINNING_GROUP_ALL) {
|
||||
continue;
|
||||
}
|
||||
printf(" fuse >= %d %d mV", pmgr_binning_voltage_index_to_config_data[i].fuse_revision_minimum, pmgr_binning_voltage_index_to_config_data[i].safe_voltage + pmgr_binning_get_voltage_offset(voltage_index, type));
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void pmgr_binning_menu_current_values_type(enum pmgr_binning_type_t type)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
uint32_t freq;
|
||||
uint32_t voltage;
|
||||
while (pmgr_platform_get_perf_state(type, i, &voltage, &freq)) {
|
||||
if (freq == 0) {
|
||||
printf(" state %u: %u mV", i, voltage);
|
||||
} else {
|
||||
printf(" state %u: %u Mhz %u mV", i, freq / 1000000, voltage);
|
||||
}
|
||||
if ((type == PMGR_BINNING_CPU) && (pmgr_platform_get_perf_state(PMGR_BINNING_CPU_SRAM, i, &voltage, &freq))) {
|
||||
printf(" SRAM %u mV", voltage);
|
||||
}
|
||||
if ((type == PMGR_BINNING_GPU) && (pmgr_platform_get_perf_state(PMGR_BINNING_GPU_SRAM, i, &voltage, &freq))) {
|
||||
printf(" SRAM %u mV", voltage);
|
||||
}
|
||||
printf("\n");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static int do_pmgr(int argc, struct cmd_arg *args)
|
||||
{
|
||||
uint32_t voltage_indexes[32];
|
||||
uint32_t max_voltage_index = 0;
|
||||
uint32_t voltage_index_found;
|
||||
if ((argc < 2) || ((strcmp(args[1].str, "binning") != 0) && (strcmp(args[1].str, "values") != 0))) {
|
||||
printf("Usage\n");
|
||||
printf(" pmgr [values | [binning [internal|values]]]\n");
|
||||
printf(" pmgr binning: fused value\n");
|
||||
printf(" pmgr binning internal: fused value and all known operating points\n");
|
||||
printf(" pmgr values: values currently set in PMGR/ACC registers\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((argc > 1) && (strcmp(args[1].str, "values") == 0)) {
|
||||
printf("CPU:\n");
|
||||
pmgr_binning_menu_current_values_type(PMGR_BINNING_CPU);
|
||||
printf("GPU:\n");
|
||||
pmgr_binning_menu_current_values_type(PMGR_BINNING_GPU);
|
||||
printf("SOC:\n");
|
||||
pmgr_binning_menu_current_values_type(PMGR_BINNING_SOC);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Fuse revision %u base %u bin group %u\n", pmgr_binning_get_revision(), pmgr_binning_get_base(), pmgr_binning_get_group());
|
||||
printf(" CPU\n");
|
||||
pmgr_binning_menu_print_type(PMGR_BINNING_CPU);
|
||||
printf(" CPU SRAM\n");
|
||||
pmgr_binning_menu_print_type(PMGR_BINNING_CPU_SRAM);
|
||||
printf(" GPU\n");
|
||||
pmgr_binning_menu_print_type(PMGR_BINNING_GPU);
|
||||
printf(" GPU SRAM\n");
|
||||
pmgr_binning_menu_print_type(PMGR_BINNING_GPU_SRAM);
|
||||
printf(" SRAM\n");
|
||||
pmgr_binning_menu_print_type(PMGR_BINNING_SRAM);
|
||||
printf(" SOC\n");
|
||||
pmgr_binning_menu_print_type(PMGR_BINNING_SOC);
|
||||
|
||||
if ((argc > 2) && (strcmp(args[2].str, "internal") == 0)) {
|
||||
uint32_t i;
|
||||
printf("\n");
|
||||
for (i = 0; i < pmgr_binning_voltage_index_to_config_data_size; i++) {
|
||||
if (pmgr_binning_voltage_index_to_config_data[i].voltage_index > max_voltage_index) {
|
||||
max_voltage_index = pmgr_binning_voltage_index_to_config_data[i].voltage_index;
|
||||
}
|
||||
}
|
||||
for (i = 0; i <= max_voltage_index; i++) {
|
||||
pmgr_binning_menu_voltage_config_print(NULL, i);
|
||||
}
|
||||
for (i = 0; i < pmgr_binning_voltage_config_sram_data_size; i++) {
|
||||
pmgr_binning_menu_voltage_config_print(&pmgr_binning_voltage_config_sram_data[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
if (pmgr_binning_menu_override_get_voltage_indexes(false, voltage_indexes, sizeof(voltage_indexes)/sizeof(voltage_indexes[0]), &voltage_index_found)) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < voltage_index_found; i++) {
|
||||
if (i == 0) {
|
||||
printf("\n\nOverridden CPU states:\n");
|
||||
}
|
||||
printf(" state %u ", i + 3); // state 0 (bypass), 1 (securerom) and 2 (current state) are not overridden
|
||||
pmgr_binning_menu_voltage_config_print(NULL, voltage_indexes[i]);
|
||||
}
|
||||
}
|
||||
if (pmgr_binning_menu_override_get_voltage_indexes(true, voltage_indexes, sizeof(voltage_indexes)/sizeof(voltage_indexes[0]), &voltage_index_found)) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < voltage_index_found; i++) {
|
||||
if (i == 0) {
|
||||
printf("\n\nOverridden GPU states:\n");
|
||||
}
|
||||
printf(" state %u ", i + 1); // state 0 (off) are not overridden
|
||||
pmgr_binning_menu_voltage_config_print(NULL, voltage_indexes[i]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pmgr_binning_menu_update_states(void)
|
||||
{
|
||||
uint32_t voltage_indexes[32];
|
||||
uint32_t voltage_index_found;
|
||||
|
||||
if (pmgr_binning_menu_override_get_voltage_indexes(false, voltage_indexes, sizeof(voltage_indexes)/sizeof(voltage_indexes[0]), &voltage_index_found)) {
|
||||
pmgr_platform_set_perf_state(false, 3, voltage_indexes, voltage_index_found);
|
||||
}
|
||||
if (pmgr_binning_menu_override_get_voltage_indexes(true, voltage_indexes, sizeof(voltage_indexes)/sizeof(voltage_indexes[0]), &voltage_index_found)) {
|
||||
pmgr_platform_set_perf_state(true, 1, voltage_indexes, voltage_index_found);
|
||||
}
|
||||
}
|
||||
|
||||
// _command, _function, _help, _meta
|
||||
MENU_COMMAND_DEVELOPMENT(pmgr, do_pmgr, "Print pmgr data", NULL);
|
||||
|
||||
#endif // !RELEASE_BUILD && WITH_MENU
|
||||
@@ -0,0 +1,42 @@
|
||||
# Copyright (C) 2015 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
LOCAL_DIR := $(GET_LOCAL_DIR)
|
||||
|
||||
# All H8+ chip must use pmgr_binning
|
||||
PMGR_BINNING=0
|
||||
|
||||
ifeq ($(SUB_PLATFORM),s8000)
|
||||
PMGR_BINNING=1
|
||||
endif
|
||||
|
||||
ifeq ($(SUB_PLATFORM),s8001)
|
||||
PMGR_BINNING=1
|
||||
endif
|
||||
|
||||
ifeq ($(SUB_PLATFORM),s8003)
|
||||
PMGR_BINNING=1
|
||||
endif
|
||||
|
||||
ifeq ($(PMGR_BINNING),1)
|
||||
ALL_OBJS += \
|
||||
$(LOCAL_DIR)/pmgr_binning.o
|
||||
|
||||
ifneq ($(BUILD),RELEASE)
|
||||
ifeq ($(PRODUCT),iBoot)
|
||||
ALL_OBJS += \
|
||||
$(LOCAL_DIR)/pmgr_binning_menu.o
|
||||
endif
|
||||
ifeq ($(PRODUCT),iBEC)
|
||||
ALL_OBJS += \
|
||||
$(LOCAL_DIR)/pmgr_binning_menu.o
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
Reference in new issue
Block a user