rezhu | c817262 | 2015-11-10 10:26:39 +0800 | [diff] [blame] | 1 | /* |
| 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 Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 24 | #ifndef _POLARIS10_SMUMANAGER_H |
| 25 | #define _POLARIS10_SMUMANAGER_H |
rezhu | c817262 | 2015-11-10 10:26:39 +0800 | [diff] [blame] | 26 | |
Rex Zhu | 34a564e | 2016-09-09 13:29:47 +0800 | [diff] [blame] | 27 | |
rezhu | c817262 | 2015-11-10 10:26:39 +0800 | [diff] [blame] | 28 | #include <pp_endian.h> |
Rex Zhu | 00d57e6 | 2016-08-11 19:36:54 +0800 | [diff] [blame] | 29 | #include "smu74.h" |
Rex Zhu | 34a564e | 2016-09-09 13:29:47 +0800 | [diff] [blame] | 30 | #include "smu74_discrete.h" |
| 31 | |
| 32 | |
| 33 | #define SMC_RAM_END 0x40000 |
rezhu | c817262 | 2015-11-10 10:26:39 +0800 | [diff] [blame] | 34 | |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 35 | struct polaris10_avfs { |
rezhu | c817262 | 2015-11-10 10:26:39 +0800 | [diff] [blame] | 36 | enum AVFS_BTC_STATUS avfs_btc_status; |
| 37 | uint32_t avfs_btc_param; |
| 38 | }; |
| 39 | |
Rex Zhu | 00d57e6 | 2016-08-11 19:36:54 +0800 | [diff] [blame] | 40 | struct 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 Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 54 | struct polaris10_buffer_entry { |
rezhu | c817262 | 2015-11-10 10:26:39 +0800 | [diff] [blame] | 55 | 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 Zhu | 00d57e6 | 2016-08-11 19:36:54 +0800 | [diff] [blame] | 62 | struct polaris10_range_table { |
| 63 | uint32_t trans_lower_frequency; /* in 10khz */ |
| 64 | uint32_t trans_upper_frequency; |
| 65 | }; |
| 66 | |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 67 | struct polaris10_smumgr { |
rezhu | c817262 | 2015-11-10 10:26:39 +0800 | [diff] [blame] | 68 | uint8_t *header; |
| 69 | uint8_t *mec_image; |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 70 | struct polaris10_buffer_entry smu_buffer; |
| 71 | struct polaris10_buffer_entry header_buffer; |
Rex Zhu | 34a564e | 2016-09-09 13:29:47 +0800 | [diff] [blame] | 72 | |
| 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 | |
rezhu | c817262 | 2015-11-10 10:26:39 +0800 | [diff] [blame] | 79 | 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; |
yanyang1 | e85c7d6 | 2016-02-06 13:28:47 +0800 | [diff] [blame] | 84 | uint8_t protected_mode; |
| 85 | uint8_t security_hard_key; |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 86 | struct polaris10_avfs avfs; |
Rex Zhu | 34a564e | 2016-09-09 13:29:47 +0800 | [diff] [blame] | 87 | 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]; |
rezhu | c817262 | 2015-11-10 10:26:39 +0800 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 97 | int polaris10_smum_init(struct pp_smumgr *smumgr); |
Flora Cui | 2cc0c0b | 2016-03-14 18:33:29 -0400 | [diff] [blame] | 98 | int polaris10_read_smc_sram_dword(struct pp_smumgr *smumgr, uint32_t smc_addr, uint32_t *value, uint32_t limit); |
| 99 | int polaris10_write_smc_sram_dword(struct pp_smumgr *smumgr, uint32_t smc_addr, uint32_t value, uint32_t limit); |
| 100 | int polaris10_copy_bytes_to_smc(struct pp_smumgr *smumgr, uint32_t smc_start_address, |
rezhu | c817262 | 2015-11-10 10:26:39 +0800 | [diff] [blame] | 101 | const uint8_t *src, uint32_t byte_count, uint32_t limit); |
| 102 | |
| 103 | #endif |