예제 #1
0
파일: edp.c 프로젝트: Shaky156/Tegra-Note-7
void tegra_platform_edp_init(struct thermal_trip_info *trips,
				int *num_trips, int margin)
{
	const struct tegra_edp_limits *cpu_edp_limits;
	struct thermal_trip_info *trip_state;
	int i, cpu_edp_limits_size;

	if (!trips || !num_trips)
		return;

	/* edp capping */
	tegra_get_cpu_edp_limits(&cpu_edp_limits, &cpu_edp_limits_size);

	if (cpu_edp_limits_size > MAX_THROT_TABLE_SIZE)
		BUG();

	for (i = 0; i < cpu_edp_limits_size-1; i++) {
		trip_state = &trips[*num_trips];

		trip_state->cdev_type = "cpu_edp";
		trip_state->trip_temp =
			(cpu_edp_limits[i].temperature * 1000) - margin;
		trip_state->trip_type = THERMAL_TRIP_ACTIVE;
		trip_state->upper = trip_state->lower = i + 1;

		(*num_trips)++;

		if (*num_trips >= THERMAL_MAX_TRIPS)
			BUG();
	}
}
static void enterprise_nct1008_init(void)
{
	int ret;
	struct nct1008_platform_data *pdata;
#ifdef CONFIG_TEGRA_EDP_LIMITS
	const struct tegra_edp_limits *z;
	int zones_sz;
	int i;
	bool throttle_ok = false;
#endif

	tegra_gpio_enable(TEGRA_GPIO_PH7);
	ret = gpio_request(TEGRA_GPIO_PH7, "temp_alert");
	if (ret < 0) {
		pr_err("%s: gpio_request failed %d\n", __func__, ret);
		return;
	}

	ret = gpio_direction_input(TEGRA_GPIO_PH7);
	if (ret < 0) {
		pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
		gpio_free(TEGRA_GPIO_PH7);
		return;
	}

	/* Temperature guardband AP30S DSC: bug 844025 */
	pdata = enterprise_i2c4_nct1008_board_info[0].platform_data;
	pdata->offset = 33; /* 4 * 8.25C */

	i2c_register_board_info(4, enterprise_i2c4_nct1008_board_info,
				ARRAY_SIZE(enterprise_i2c4_nct1008_board_info));
#ifdef CONFIG_TEGRA_EDP_LIMITS
	tegra_get_cpu_edp_limits(&z, &zones_sz);
	zones_sz = min(zones_sz, MAX_ZONES);
	for (i = 0; i < zones_sz; i++) {
		enterprise_nct1008_pdata.thermal_zones[i] = z[i].temperature;
		if (enterprise_nct1008_pdata.thermal_zones[i] ==
		    enterprise_nct1008_pdata.throttling_ext_limit) {
			throttle_ok = true;
		}
	}

	if (throttle_ok != true)
		pr_warn("%s: WARNING! Throttling limit %dC would be inaccurate"
			" as it is NOT one of the EDP points\n",
			__func__, enterprise_nct1008_pdata.throttling_ext_limit);
	else
		pr_info("%s: Throttling limit %dC OK\n",
			__func__, enterprise_nct1008_pdata.throttling_ext_limit);

	enterprise_nct1008_pdata.thermal_zones_sz = zones_sz;
#endif
}
예제 #3
0
static int edp_debugfs_show(struct seq_file *s, void *data)
{
	int i;
	const struct tegra_edp_limits *limits;
	int size;

	tegra_get_cpu_edp_limits(&limits, &size);

	seq_printf(s, "-- EDP table --\n");
	for (i = 0; i < size; i++) {
		seq_printf(s, "%4dC: %10d %10d %10d %10d\n",
			   limits[i].temperature,
			   limits[i].freq_limits[0],
			   limits[i].freq_limits[1],
			   limits[i].freq_limits[2],
			   limits[i].freq_limits[3]);
	}

	return 0;
}
static int cardhu_nct1008_init(void)
{
	int nct1008_port = -1;
	int ret;
#ifdef CONFIG_TEGRA_EDP_LIMITS
	const struct tegra_edp_limits *z;
	int zones_sz;
	int i;
	bool throttle_ok = false;
#endif

	if ((board_info.board_id == BOARD_E1198) ||
		(board_info.board_id == BOARD_E1291) ||
		(board_info.board_id == BOARD_PM269)) {
		nct1008_port = TEGRA_GPIO_PCC2;
	} else if ((board_info.board_id == BOARD_E1186) ||
		(board_info.board_id == BOARD_E1187) ||
		(board_info.board_id == BOARD_E1256)) {
		/* FIXME: seems to be conflicting with usb3 vbus on E1186 */
		/* nct1008_port = TEGRA_GPIO_PH7; */
	}
	nct1008_port = TEGRA_GPIO_PCC2;

	if (nct1008_port >= 0) {
		/* FIXME: enable irq when throttling is supported */
		cardhu_i2c4_nct1008_board_info[0].irq = TEGRA_GPIO_TO_IRQ(nct1008_port);

		ret = gpio_request(nct1008_port, "temp_alert");
		if (ret < 0)
			return ret;

		ret = gpio_direction_input(nct1008_port);
		if (ret < 0)
			gpio_free(nct1008_port);
		else
			tegra_gpio_enable(nct1008_port);
	}

#ifdef CONFIG_TEGRA_EDP_LIMITS
	tegra_get_cpu_edp_limits(&z, &zones_sz);
	zones_sz = min(zones_sz, MAX_ZONES);
	for (i = 0; i < zones_sz; i++) {
		cardhu_nct1008_pdata.thermal_zones[i] = z[i].temperature;
		if (cardhu_nct1008_pdata.thermal_zones[i] ==
		    cardhu_nct1008_pdata.throttling_ext_limit) {
			throttle_ok = true;
		}
	}

	if (throttle_ok != true)
		pr_warn("%s: WARNING! Throttling limit %dC would be inaccurate"
			" as it is NOT one of the EDP points\n",
			__func__, cardhu_nct1008_pdata.throttling_ext_limit);
	else
		pr_info("%s: Throttling limit %dC OK\n",
			__func__, cardhu_nct1008_pdata.throttling_ext_limit);

	cardhu_nct1008_pdata.thermal_zones_sz = zones_sz;
#endif
	return ret;
}