1*17fcb3dcSFan Gong // SPDX-License-Identifier: GPL-2.0 2*17fcb3dcSFan Gong // Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. 3*17fcb3dcSFan Gong 4*17fcb3dcSFan Gong #include <linux/delay.h> 5*17fcb3dcSFan Gong 6*17fcb3dcSFan Gong #include "hinic3_hw_comm.h" 7*17fcb3dcSFan Gong #include "hinic3_hwdev.h" 8*17fcb3dcSFan Gong #include "hinic3_hwif.h" 9*17fcb3dcSFan Gong #include "hinic3_mbox.h" 10*17fcb3dcSFan Gong 11*17fcb3dcSFan Gong int hinic3_func_reset(struct hinic3_hwdev *hwdev, u16 func_id, u64 reset_flag) 12*17fcb3dcSFan Gong { 13*17fcb3dcSFan Gong struct comm_cmd_func_reset func_reset = {}; 14*17fcb3dcSFan Gong struct mgmt_msg_params msg_params = {}; 15*17fcb3dcSFan Gong int err; 16*17fcb3dcSFan Gong 17*17fcb3dcSFan Gong func_reset.func_id = func_id; 18*17fcb3dcSFan Gong func_reset.reset_flag = reset_flag; 19*17fcb3dcSFan Gong 20*17fcb3dcSFan Gong mgmt_msg_params_init_default(&msg_params, &func_reset, 21*17fcb3dcSFan Gong sizeof(func_reset)); 22*17fcb3dcSFan Gong 23*17fcb3dcSFan Gong err = hinic3_send_mbox_to_mgmt(hwdev, MGMT_MOD_COMM, 24*17fcb3dcSFan Gong COMM_CMD_FUNC_RESET, &msg_params); 25*17fcb3dcSFan Gong if (err || func_reset.head.status) { 26*17fcb3dcSFan Gong dev_err(hwdev->dev, "Failed to reset func resources, reset_flag 0x%llx, err: %d, status: 0x%x\n", 27*17fcb3dcSFan Gong reset_flag, err, func_reset.head.status); 28*17fcb3dcSFan Gong return -EIO; 29*17fcb3dcSFan Gong } 30*17fcb3dcSFan Gong 31*17fcb3dcSFan Gong return 0; 32*17fcb3dcSFan Gong } 33