1 /* 2 * Copyright 2022 Red Hat 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 #include "priv.h" 23 24 #include <subdev/mc.h> 25 #include <subdev/timer.h> 26 27 int 28 gm200_flcn_reset_wait_mem_scrubbing(struct nvkm_falcon *falcon) 29 { 30 nvkm_falcon_mask(falcon, 0x040, 0x00000000, 0x00000000); 31 32 if (nvkm_msec(falcon->owner->device, 10, 33 if (!(nvkm_falcon_rd32(falcon, 0x10c) & 0x00000006)) 34 break; 35 ) < 0) 36 return -ETIMEDOUT; 37 38 return 0; 39 } 40 41 int 42 gm200_flcn_enable(struct nvkm_falcon *falcon) 43 { 44 struct nvkm_device *device = falcon->owner->device; 45 int ret; 46 47 if (falcon->func->reset_eng) { 48 ret = falcon->func->reset_eng(falcon); 49 if (ret) 50 return ret; 51 } 52 53 if (falcon->func->reset_pmc) 54 nvkm_mc_enable(device, falcon->owner->type, falcon->owner->inst); 55 56 ret = falcon->func->reset_wait_mem_scrubbing(falcon); 57 if (ret) 58 return ret; 59 60 nvkm_falcon_wr32(falcon, 0x084, nvkm_rd32(device, 0x000000)); 61 return 0; 62 } 63 64 int 65 gm200_flcn_disable(struct nvkm_falcon *falcon) 66 { 67 struct nvkm_device *device = falcon->owner->device; 68 int ret; 69 70 nvkm_falcon_mask(falcon, 0x048, 0x00000003, 0x00000000); 71 nvkm_falcon_wr32(falcon, 0x014, 0xffffffff); 72 73 if (falcon->func->reset_pmc) 74 nvkm_mc_disable(device, falcon->owner->type, falcon->owner->inst); 75 76 if (falcon->func->reset_eng) { 77 ret = falcon->func->reset_eng(falcon); 78 if (ret) 79 return ret; 80 } 81 82 return 0; 83 } 84