void pal_fix_Sensorconfig()

in meta-facebook/yv35-cl/src/sensor/plat_sensor.c [270:353]


void pal_fix_Sensorconfig()
{
	uint8_t sensor_count = sizeof(plat_sensor_config) / sizeof(plat_sensor_config[0]);

	/* check sensor type of VR */
	for (uint8_t index = 0; index < sensor_count; index++) {
		if (sensor_config[index].type == sensor_dev_isl69259) {
			check_vr_type(index);
		}
	}

	/* Fix sensor table according to the different class types and board revisions */
	if (get_bic_class() == sys_class_1) {
		uint8_t board_revision = get_board_revision();
		switch (board_revision) {
		case SYS_BOARD_POC:
		case SYS_BOARD_EVT:
		case SYS_BOARD_EVT2:
			sensor_count = sizeof(class1_adm1278_sensor_config_table) /
				       sizeof(class1_adm1278_sensor_config_table[0]);
			while (sensor_count) {
				add_Sensorconfig(
					class1_adm1278_sensor_config_table[sensor_count - 1]);
				sensor_count--;
			}
			break;
		case SYS_BOARD_EVT3_EFUSE:
		case SYS_BOARD_DVT_EFUSE:
		case SYS_BOARD_MP_EFUSE:
			sensor_count = sizeof(class1_mp5990_sensor_config_table) /
				       sizeof(class1_mp5990_sensor_config_table[0]);
			while (sensor_count) {
				if (get_2ou_status()) {
					/* For the class type 1 and 2OU system,
					 * set the IMON based total over current fault limit to 70A(0x0046),
					 * set the gain for output current reporting to 0x01BF following the power team's experiment
					 * and set GPIOA7(HSC_SET_EN_R) to high.
					 */
					class1_mp5990_sensor_config_table[sensor_count - 1]
						.init_args = &mp5990_init_args[1];
					gpio_set(HSC_SET_EN_R, GPIO_HIGH);
				} else {
					/* For the class type 1 and 2OU system,
					 * set the IMON based total over current fault limit to 40A(0x0028),
					 * set the gain for output current reporting to 0x0104 following the power team's experiment
					 * and set GPIOA7(HSC_SET_EN_R) to low.
					 */
					class1_mp5990_sensor_config_table[sensor_count - 1]
						.init_args = &mp5990_init_args[0];
					gpio_set(HSC_SET_EN_R, GPIO_LOW);
				}
				add_Sensorconfig(
					class1_mp5990_sensor_config_table[sensor_count - 1]);
				sensor_count--;
			}
			break;
		case SYS_BOARD_EVT3_HOTSWAP:
		case SYS_BOARD_DVT_HOTSWAP:
		case SYS_BOARD_MP_HOTSWAP:
			sensor_count = ARRAY_SIZE(class1_adm1278_sensor_config_table);
			while (sensor_count != 0) {
				add_Sensorconfig(
					class1_adm1278_sensor_config_table[--sensor_count]);
				if (sensor_count == 0) {
					break;
				}
			}
			/* Replace the temperature sensors configuration including "HSC Temp" and "MB Outlet Temp."
			 * For these two sensors, the reading values are read from TMP431 chip.data.num
			 */
			sensor_count = ARRAY_SIZE(evt3_class1_adi_temperature_sensor_table);
			while (sensor_count != 0) {
				add_Sensorconfig(
					evt3_class1_adi_temperature_sensor_table[--sensor_count]);
				if (sensor_count == 0) {
					break;
				}
			}
			break;
		default:
			break;
		}
	}
};