1 /* $NetBSD: dmcu.h,v 1.2 2021/12/18 23:45:05 riastradh Exp $ */ 2 3 /* Copyright 2012-15 Advanced Micro Devices, Inc. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * OTHER DEALINGS IN THE SOFTWARE. 22 * 23 * Authors: AMD 24 * 25 */ 26 27 #ifndef __DC_DMCU_H__ 28 #define __DC_DMCU_H__ 29 30 #include "dm_services_types.h" 31 32 /* If HW itself ever powered down it will be 0. 33 * fwDmcuInit will write to 1. 34 * Driver will only call MCP init if current state is 1, 35 * and the MCP command will transition this to 2. 36 */ 37 enum dmcu_state { 38 DMCU_UNLOADED = 0, 39 DMCU_LOADED_UNINITIALIZED = 1, 40 DMCU_RUNNING = 2, 41 }; 42 43 struct dmcu_version { 44 unsigned int interface_version; 45 unsigned int abm_version; 46 unsigned int psr_version; 47 unsigned int build_version; 48 }; 49 50 struct dmcu { 51 struct dc_context *ctx; 52 const struct dmcu_funcs *funcs; 53 54 enum dmcu_state dmcu_state; 55 struct dmcu_version dmcu_version; 56 unsigned int cached_wait_loop_number; 57 uint32_t psp_version; 58 bool auto_load_dmcu; 59 }; 60 61 struct dmcu_funcs { 62 bool (*dmcu_init)(struct dmcu *dmcu); 63 bool (*load_iram)(struct dmcu *dmcu, 64 unsigned int start_offset, 65 const char *src, 66 unsigned int bytes); 67 void (*set_psr_enable)(struct dmcu *dmcu, bool enable, bool wait); 68 bool (*setup_psr)(struct dmcu *dmcu, 69 struct dc_link *link, 70 struct psr_context *psr_context); 71 void (*get_psr_state)(struct dmcu *dmcu, uint32_t *psr_state); 72 void (*set_psr_wait_loop)(struct dmcu *dmcu, 73 unsigned int wait_loop_number); 74 void (*get_psr_wait_loop)(struct dmcu *dmcu, 75 unsigned int *psr_wait_loop_number); 76 bool (*is_dmcu_initialized)(struct dmcu *dmcu); 77 bool (*lock_phy)(struct dmcu *dmcu); 78 bool (*unlock_phy)(struct dmcu *dmcu); 79 }; 80 81 #endif 82