blob: 1ab9b1d9df9a999b47d076450ae906f4cb058dbf [file] [log] [blame]
rezhuc8172622015-11-10 10:26:39 +08001/*
2 * Copyright 2015 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 */
23
Flora Cui2cc0c0b2016-03-14 18:33:29 -040024#ifndef _POLARIS10_SMUMANAGER_H
25#define _POLARIS10_SMUMANAGER_H
rezhuc8172622015-11-10 10:26:39 +080026
Rex Zhu34a564e2016-09-09 13:29:47 +080027
rezhuc8172622015-11-10 10:26:39 +080028#include <pp_endian.h>
Rex Zhu00d57e62016-08-11 19:36:54 +080029#include "smu74.h"
Rex Zhu34a564e2016-09-09 13:29:47 +080030#include "smu74_discrete.h"
31
32
33#define SMC_RAM_END 0x40000
rezhuc8172622015-11-10 10:26:39 +080034
Flora Cui2cc0c0b2016-03-14 18:33:29 -040035struct polaris10_avfs {
rezhuc8172622015-11-10 10:26:39 +080036 enum AVFS_BTC_STATUS avfs_btc_status;
37 uint32_t avfs_btc_param;
38};
39
Rex Zhu00d57e62016-08-11 19:36:54 +080040struct polaris10_pt_defaults {
41 uint8_t SviLoadLineEn;
42 uint8_t SviLoadLineVddC;
43 uint8_t TDC_VDDC_ThrottleReleaseLimitPerc;
44 uint8_t TDC_MAWt;
45 uint8_t TdcWaterfallCtl;
46 uint8_t DTEAmbientTempBase;
47
48 uint32_t DisplayCac;
49 uint32_t BAPM_TEMP_GRADIENT;
50 uint16_t BAPMTI_R[SMU74_DTE_ITERATIONS * SMU74_DTE_SOURCES * SMU74_DTE_SINKS];
51 uint16_t BAPMTI_RC[SMU74_DTE_ITERATIONS * SMU74_DTE_SOURCES * SMU74_DTE_SINKS];
52};
53
Flora Cui2cc0c0b2016-03-14 18:33:29 -040054struct polaris10_buffer_entry {
rezhuc8172622015-11-10 10:26:39 +080055 uint32_t data_size;
56 uint32_t mc_addr_low;
57 uint32_t mc_addr_high;
58 void *kaddr;
59 unsigned long handle;
60};
61
Rex Zhu00d57e62016-08-11 19:36:54 +080062struct polaris10_range_table {
63 uint32_t trans_lower_frequency; /* in 10khz */
64 uint32_t trans_upper_frequency;
65};
66
Flora Cui2cc0c0b2016-03-14 18:33:29 -040067struct polaris10_smumgr {
rezhuc8172622015-11-10 10:26:39 +080068 uint8_t *header;
69 uint8_t *mec_image;
Flora Cui2cc0c0b2016-03-14 18:33:29 -040070 struct polaris10_buffer_entry smu_buffer;
71 struct polaris10_buffer_entry header_buffer;
Rex Zhu34a564e2016-09-09 13:29:47 +080072
73 uint32_t soft_regs_start;
74 uint32_t dpm_table_start;
75 uint32_t mc_reg_table_start;
76 uint32_t fan_table_start;
77 uint32_t arb_table_start;
78
rezhuc8172622015-11-10 10:26:39 +080079 uint8_t *read_rrm_straps;
80 uint32_t read_drm_straps_mc_address_high;
81 uint32_t read_drm_straps_mc_address_low;
82 uint32_t acpi_optimization;
83 bool post_initial_boot;
yanyang1e85c7d62016-02-06 13:28:47 +080084 uint8_t protected_mode;
85 uint8_t security_hard_key;
Flora Cui2cc0c0b2016-03-14 18:33:29 -040086 struct polaris10_avfs avfs;
Rex Zhu34a564e2016-09-09 13:29:47 +080087 SMU74_Discrete_DpmTable smc_state_table;
88 struct SMU74_Discrete_Ulv ulv_setting;
89 struct SMU74_Discrete_PmFuses power_tune_table;
90 struct polaris10_range_table range_table[NUM_SCLK_RANGE];
91 const struct polaris10_pt_defaults *power_tune_defaults;
92 uint32_t activity_target[SMU74_MAX_LEVELS_GRAPHICS];
93 uint32_t bif_sclk_table[SMU74_MAX_LEVELS_LINK];
rezhuc8172622015-11-10 10:26:39 +080094};
95
96
Flora Cui2cc0c0b2016-03-14 18:33:29 -040097int polaris10_smum_init(struct pp_smumgr *smumgr);
Flora Cui2cc0c0b2016-03-14 18:33:29 -040098int polaris10_read_smc_sram_dword(struct pp_smumgr *smumgr, uint32_t smc_addr, uint32_t *value, uint32_t limit);
99int polaris10_write_smc_sram_dword(struct pp_smumgr *smumgr, uint32_t smc_addr, uint32_t value, uint32_t limit);
100int polaris10_copy_bytes_to_smc(struct pp_smumgr *smumgr, uint32_t smc_start_address,
rezhuc8172622015-11-10 10:26:39 +0800101 const uint8_t *src, uint32_t byte_count, uint32_t limit);
102
103#endif