Esempio n. 1
0
static int
acpi_thermal_critical (
	struct acpi_thermal	*tz)
{
	int			result = 0;
	struct acpi_device	*device = NULL;

	ACPI_FUNCTION_TRACE("acpi_thermal_critical");

	if (!tz || !tz->trips.critical.flags.valid)
		return_VALUE(-EINVAL);

	if (tz->temperature >= tz->trips.critical.temperature) {
		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n"));
		tz->trips.critical.flags.enabled = 1;
	}
	else if (tz->trips.critical.flags.enabled)
		tz->trips.critical.flags.enabled = 0;

	result = acpi_bus_get_device(tz->handle, &device);
	if (result)
		return_VALUE(result);

	printk(KERN_EMERG "Critical temperature reached (%ld C), shutting down.\n", KELVIN_TO_CELSIUS(tz->temperature));
	acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_CRITICAL, tz->trips.critical.flags.enabled);

	acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF);

	return_VALUE(0);
}
Esempio n. 2
0
static int
acpi_thermal_critical (
	struct acpi_thermal	*tz)
{
	int			result = 0;
	struct acpi_device	*device = NULL;

	ACPI_FUNCTION_TRACE("acpi_thermal_critical");

	if (!tz || !tz->trips.critical.flags.valid)
		return_VALUE(-EINVAL);

	if (tz->temperature >= tz->trips.critical.temperature) {
		ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n"));
		tz->trips.critical.flags.enabled = 1;
	}
	else if (tz->trips.critical.flags.enabled)
		tz->trips.critical.flags.enabled = 0;

	
	printk("ACPI: Critical temperature reached (%ld C), shutting down.\n", KELVIN_TO_CELSIUS(tz->temperature));

	reboot();

	return_VALUE(0);
}
Esempio n. 3
0
static int
acpi_thermal_add (
	struct acpi_device 		*device)
{
	int			result = 0;
	acpi_status		status = AE_OK;
	struct acpi_thermal	*tz = NULL;

	ACPI_FUNCTION_TRACE("acpi_thermal_add");

	if (!device)
		return_VALUE(-EINVAL);

	tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
	if (!tz)
		return_VALUE(-ENOMEM);
	memset(tz, 0, sizeof(struct acpi_thermal));

	tz->handle = device->handle;
	sprintf(tz->name, "%s", device->pnp.bus_id);
	sprintf(acpi_device_name(device), "%s", ACPI_THERMAL_DEVICE_NAME);
	sprintf(acpi_device_class(device), "%s", ACPI_THERMAL_CLASS);
	acpi_driver_data(device) = tz;

	result = acpi_thermal_get_info(tz);
	if (result)
		goto end;

	result = acpi_thermal_add_fs(device);
	if (result)
		return_VALUE(result);

	init_timer(&tz->timer);

	acpi_thermal_check(tz);

	status = acpi_install_notify_handler(tz->handle,
		ACPI_DEVICE_NOTIFY, acpi_thermal_notify, tz);
	if (ACPI_FAILURE(status)) {
		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
			"Error installing notify handler\n"));
		result = -ENODEV;
		goto end;
	}

	printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
		acpi_device_name(device), acpi_device_bid(device),
		KELVIN_TO_CELSIUS(tz->temperature));

end:
	if (result) {
		acpi_thermal_remove_fs(device);
		kfree(tz);
	}

	return_VALUE(result);
}
Esempio n. 4
0
static void iwl5150_temperature(struct iwl_priv *priv)
{
	u32 vt = 0;
	s32 offset =  iwl_temp_calib_to_offset(priv);

	vt = le32_to_cpu(priv->statistics.general.temperature);
	vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset;
	/* now vt hold the temperature in Kelvin */
	priv->temperature = KELVIN_TO_CELSIUS(vt);
}
static void iwl5150_temperature(struct iwl_priv *priv)
{
    u32 vt = 0;
    s32 offset =  iwl_temp_calib_to_offset(priv->shrd);

    vt = le32_to_cpu(priv->statistics.common.temperature);
    vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset;

    priv->temperature = KELVIN_TO_CELSIUS(vt);
    iwl_tt_handler(priv);
}
Esempio n. 6
0
static void iwl_bg_tt_work(struct work_struct *work)
{
	struct iwl_priv *priv = container_of(work, struct iwl_priv, tt_work);
	s32 temp = priv->temperature; /* degrees CELSIUS except 4965 */

	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
		return;

	if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)
		temp = KELVIN_TO_CELSIUS(priv->temperature);

	if (!priv->thermal_throttle.advanced_tt)
		iwl_legacy_tt_handler(priv, temp, false);
	else
		iwl_advance_tt_handler(priv, temp, false);
}
Esempio n. 7
0
bool iwl_within_ct_kill_margin(struct iwl_priv *priv)
{
	s32 temp = priv->temperature; /* degrees CELSIUS except 4965 */
	bool within_margin = false;

	if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)
		temp = KELVIN_TO_CELSIUS(priv->temperature);

	if (!priv->thermal_throttle.advanced_tt)
		within_margin = ((temp + IWL_TT_CT_KILL_MARGIN) >=
				CT_KILL_THRESHOLD_LEGACY) ? true : false;
	else
		within_margin = ((temp + IWL_TT_CT_KILL_MARGIN) >=
				CT_KILL_THRESHOLD) ? true : false;
	return within_margin;
}
Esempio n. 8
0
static int acpi_thermal_add(struct acpi_device *device)
{
	int result = 0;
	struct acpi_thermal *tz = NULL;


	if (!device)
		return -EINVAL;

	tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
	if (!tz)
		return -ENOMEM;

	tz->device = device;
	strcpy(tz->name, device->pnp.bus_id);
	strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
	strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
	device->driver_data = tz;
	mutex_init(&tz->lock);


	result = acpi_thermal_get_info(tz);
	if (result)
		goto free_memory;

	acpi_thermal_guess_offset(tz);

	result = acpi_thermal_register_thermal_zone(tz);
	if (result)
		goto free_memory;

	printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n",
	       acpi_device_name(device), acpi_device_bid(device),
	       KELVIN_TO_CELSIUS(tz->temperature));
	goto end;

free_memory:
	kfree(tz);
end:
	return result;
}
Esempio n. 9
0
static int
acpi_thermal_read_temperature (
	char			*page,
	char			**start,
	off_t			off,
	int 			count,
	int 			*eof,
	void			*data)
{
	int			result = 0;
	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
	char			*p = page;
	int			len = 0;

	ACPI_FUNCTION_TRACE("acpi_thermal_read_temperature");

	if (!tz || (off != 0))
		goto end;

	result = acpi_thermal_get_temperature(tz);
	if (result)
		goto end;

	p += sprintf(p, "temperature:             %ld C\n", 
		KELVIN_TO_CELSIUS(tz->temperature));
	
end:
	len = (p - page);
	if (len <= off+count) *eof = 1;
	*start = page + off;
	len -= off;
	if (len>count) len = count;
	if (len<0) len = 0;

	return_VALUE(len);
}
Esempio n. 10
0
static int
acpi_thermal_read_trip_points (
	char			*page,
	char			**start,
	off_t			off,
	int 			count,
	int 			*eof,
	void			*data)
{
	struct acpi_thermal	*tz = (struct acpi_thermal *) data;
	char			*p = page;
	int			len = 0;
	int			i = 0;
	int			j = 0;

	ACPI_FUNCTION_TRACE("acpi_thermal_read_trip_points");

	if (!tz || (off != 0))
		goto end;

	if (tz->trips.critical.flags.valid)
		p += sprintf(p, "critical (S5):           %ld C\n",
			KELVIN_TO_CELSIUS(tz->trips.critical.temperature));

	if (tz->trips.hot.flags.valid)
		p += sprintf(p, "hot (S4):                %ld C\n",
			KELVIN_TO_CELSIUS(tz->trips.hot.temperature));

	if (tz->trips.passive.flags.valid) {
		p += sprintf(p, "passive:                 %ld C: tc1=%lu tc2=%lu tsp=%lu devices=",
			KELVIN_TO_CELSIUS(tz->trips.passive.temperature),
			tz->trips.passive.tc1,
			tz->trips.passive.tc2, 
			tz->trips.passive.tsp);
		for (j=0; j<tz->trips.passive.devices.count; j++) {

			p += sprintf(p, "0x%p ", tz->trips.passive.devices.handles[j]);
		}
		p += sprintf(p, "\n");
	}

	for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) {
		if (!(tz->trips.active[i].flags.valid))
			break;
		p += sprintf(p, "active[%d]:               %ld C: devices=",
			i, KELVIN_TO_CELSIUS(tz->trips.active[i].temperature));
		for (j=0; j<tz->trips.active[i].devices.count; j++) 
			p += sprintf(p, "0x%p ",
				tz->trips.active[i].devices.handles[j]);
		p += sprintf(p, "\n");
	}

end:
	len = (p - page);
	if (len <= off+count) *eof = 1;
	*start = page + off;
	len -= off;
	if (len>count) len = count;
	if (len<0) len = 0;

	return_VALUE(len);
}
Esempio n. 11
0
static int
acpi_thermal_get_trip_points (
	struct acpi_thermal *tz)
{
	acpi_status		status = AE_OK;
	int			i = 0;

	ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points");

	if (!tz)
		return_VALUE(-EINVAL);

	/* Critical Shutdown (required) */

	status = acpi_evaluate_integer(tz->handle, "_CRT", NULL, 
		&tz->trips.critical.temperature);
	if (ACPI_FAILURE(status)) {
		tz->trips.critical.flags.valid = 0;
		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n"));
		return_VALUE(-ENODEV);
	}
	else {
		tz->trips.critical.flags.valid = 1;
		printk( "ACPI: Found critical threshold [%lu]\n", KELVIN_TO_CELSIUS(tz->trips.critical.temperature));
	}

	/* Critical Sleep (optional) */

	status = acpi_evaluate_integer(tz->handle, "_HOT", NULL, &tz->trips.hot.temperature);
	if (ACPI_FAILURE(status)) {
		tz->trips.hot.flags.valid = 0;
		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No hot threshold\n"));
	}
	else {
		tz->trips.hot.flags.valid = 1;
		printk( "ACPI: Found hot threshold [%lu]\n", KELVIN_TO_CELSIUS(tz->trips.hot.temperature));
	}

	/* Passive: Processors (optional) */

	status = acpi_evaluate_integer(tz->handle, "_PSV", NULL, &tz->trips.passive.temperature);
	if (ACPI_FAILURE(status)) {
		tz->trips.passive.flags.valid = 0;
		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No passive threshold\n"));
	}
	else {
		tz->trips.passive.flags.valid = 1;

		status = acpi_evaluate_integer(tz->handle, "_TC1", NULL, &tz->trips.passive.tc1);
		if (ACPI_FAILURE(status))
			tz->trips.passive.flags.valid = 0;

		status = acpi_evaluate_integer(tz->handle, "_TC2", NULL, &tz->trips.passive.tc2);
		if (ACPI_FAILURE(status))
			tz->trips.passive.flags.valid = 0;

		status = acpi_evaluate_integer(tz->handle, "_TSP", NULL, &tz->trips.passive.tsp);
		if (ACPI_FAILURE(status))
			tz->trips.passive.flags.valid = 0;

		status = acpi_evaluate_reference(tz->handle, "_PSL", NULL, &tz->trips.passive.devices);
		if (ACPI_FAILURE(status))
			tz->trips.passive.flags.valid = 0;

		if (!tz->trips.passive.flags.valid)
			ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid passive threshold\n"));
		else
			printk( "ACPI: Found passive threshold [%lu]\n", KELVIN_TO_CELSIUS(tz->trips.passive.temperature));
	}

	/* Active: Fans, etc. (optional) */

	for (i=0; i<ACPI_THERMAL_MAX_ACTIVE; i++) {

		char name[5] = {'_','A','C',('0'+i),'\0'};

		status = acpi_evaluate_integer(tz->handle, name, NULL, &tz->trips.active[i].temperature);
		if (ACPI_FAILURE(status))
			break;

		name[2] = 'L';
		status = acpi_evaluate_reference(tz->handle, name, NULL, &tz->trips.active[i].devices);
		if (ACPI_SUCCESS(status)) {
			tz->trips.active[i].flags.valid = 1;
			printk( "ACPI: Found active threshold [%d]:[%lu]\n", i, KELVIN_TO_CELSIUS(tz->trips.active[i].temperature));
		}
		else
			ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid active threshold [%d]\n", i));
	}

	return_VALUE(0);
}