void pal_OEM_SET_FAN_DUTY_MANUAL()

in meta-facebook/yv35-bb/src/ipmi/plat_ipmi.c [822:886]


void pal_OEM_SET_FAN_DUTY_MANUAL(ipmi_msg *msg)
{
	/*********************************
		data 0: fan pwm index
		data 1: duty
	***********************************/
	if (msg == NULL) {
		printf("%s failed due to parameter *msg is NULL\n", __func__);
		return;
	}

	if (msg->data_len != 2) {
		msg->completion_code = CC_INVALID_LENGTH;
		return;
	}
	uint8_t pwm_id = msg->data[0];
	uint8_t duty = msg->data[1];
	uint8_t current_fan_mode = FAN_AUTO_MODE, slot_index = 0;
	int ret = 0, i = 0;

	msg->data_len = 0;
	msg->completion_code = CC_SUCCESS;

	if (msg->InF_source == SLOT1_BIC_IFs) {
		slot_index = 0x01;
	} else if (msg->InF_source == SLOT3_BIC_IFs) {
		slot_index = 0x03;
	} else {
		msg->completion_code = CC_PARAM_OUT_OF_RANGE;
		return;
	}

	if ((duty > MAX_FAN_DUTY) || ((pwm_id >= MAX_FAN_PWM_INDEX) && (pwm_id != ID_ALL_PWM))) {
		msg->completion_code = CC_PARAM_OUT_OF_RANGE;
		return;
	}

	ret = pal_get_fan_ctrl_mode(&current_fan_mode);
	if (ret < 0) {
		msg->completion_code = CC_UNSPECIFIED_ERROR;
		return;
	}

	if (current_fan_mode != FAN_MANUAL_MODE) {
		printf("%s() is called when it's not at manual mode\n", __func__);
		return;
	}

	if (pwm_id == ID_ALL_PWM) {
		for (i = 0; i < MAX_FAN_PWM_INDEX; i++) {
			ret = pal_set_fan_duty(i, duty, slot_index);
			if (ret < 0) {
				msg->completion_code = CC_UNSPECIFIED_ERROR;
				break;
			}
		}
	} else {
		ret = pal_set_fan_duty(pwm_id, duty, slot_index);
		if (ret < 0) {
			msg->completion_code = CC_UNSPECIFIED_ERROR;
		}
	}

	return;
}