Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75a29ec1 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull thermal management fixes from Zhang Rui:
 "Specifics:

 - several fixes and cleanups on Rockchip thermal drivers.

 - add the missing support of RK3368 SoCs in Rockchip driver.

 - small fixes on of-thermal, power_allocator, rcar driver, IMX, and
   QCOM drivers, and also compilation fixes, on thermal.h, when thermal
   is not selected"

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
  imx: thermal: use CPU temperature grade info for thresholds
  thermal: fix thermal_zone_bind_cooling_device prototype
  Revert "thermal: qcom_spmi: allow compile test"
  thermal: rcar_thermal: remove redundant operation
  thermal: of-thermal: Reduce log level for message when can't fine thermal zone
  thermal: power_allocator: Use temperature reading from tz
  thermal: rockchip: Support the RK3368 SoCs in thermal driver
  thermal: rockchip: consistently use int for temperatures
  thermal: rockchip: Add the sort mode for adc value increment or decrement
  thermal: rockchip: improve the conversion function
  thermal: rockchip: trivial: fix typo in commit
  thermal: rockchip: better to compatible the driver for different SoCs
  dt-bindings: rockchip-thermal: Support the RK3368 SoCs compatible
parents 081f3698 a2291bad
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
* Temperature Sensor ADC (TSADC) on rockchip SoCs

Required properties:
- compatible : "rockchip,rk3288-tsadc"
- compatible : should be "rockchip,<name>-tsadc"
   "rockchip,rk3288-tsadc": found on RK3288 SoCs
   "rockchip,rk3368-tsadc": found on RK3368 SoCs
- reg : physical base address of the controller and length of memory mapped
	region.
- interrupts : The interrupt number to the cpu. The interrupt specifier format
+1 −1
Original line number Diff line number Diff line
@@ -382,7 +382,7 @@ endmenu

config QCOM_SPMI_TEMP_ALARM
	tristate "Qualcomm SPMI PMIC Temperature Alarm"
	depends on OF && (SPMI || COMPILE_TEST) && IIO
	depends on OF && SPMI && IIO
	select REGMAP_SPMI
	help
	  This enables a thermal sysfs driver for Qualcomm plug-and-play (QPNP)
+41 −15
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
#define TEMPSENSE2_PANIC_VALUE_SHIFT	16
#define TEMPSENSE2_PANIC_VALUE_MASK	0xfff0000

#define OCOTP_MEM0			0x0480
#define OCOTP_ANA1			0x04e0

/* The driver supports 1 passive trip point and 1 critical trip point */
@@ -64,12 +65,6 @@ enum imx_thermal_trip {
	IMX_TRIP_NUM,
};

/*
 * It defines the temperature in millicelsius for passive trip point
 * that will trigger cooling action when crossed.
 */
#define IMX_TEMP_PASSIVE		85000

#define IMX_POLLING_DELAY		2000 /* millisecond */
#define IMX_PASSIVE_DELAY		1000

@@ -100,12 +95,14 @@ struct imx_thermal_data {
	u32 c1, c2; /* See formula in imx_get_sensor_data() */
	int temp_passive;
	int temp_critical;
	int temp_max;
	int alarm_temp;
	int last_temp;
	bool irq_enabled;
	int irq;
	struct clk *thermal_clk;
	const struct thermal_soc_data *socdata;
	const char *temp_grade;
};

static void imx_set_panic_temp(struct imx_thermal_data *data,
@@ -285,10 +282,12 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
{
	struct imx_thermal_data *data = tz->devdata;

	/* do not allow changing critical threshold */
	if (trip == IMX_TRIP_CRITICAL)
		return -EPERM;

	if (temp < 0 || temp > IMX_TEMP_PASSIVE)
	/* do not allow passive to be set higher than critical */
	if (temp < 0 || temp > data->temp_critical)
		return -EINVAL;

	data->temp_passive = temp;
@@ -404,17 +403,39 @@ static int imx_get_sensor_data(struct platform_device *pdev)
	data->c1 = temp64;
	data->c2 = n1 * data->c1 + 1000 * t1;

	/*
	 * Set the default passive cooling trip point,
	 * can be changed from userspace.
	 */
	data->temp_passive = IMX_TEMP_PASSIVE;
	/* use OTP for thermal grade */
	ret = regmap_read(map, OCOTP_MEM0, &val);
	if (ret) {
		dev_err(&pdev->dev, "failed to read temp grade: %d\n", ret);
		return ret;
	}

	/* The maximum die temp is specified by the Temperature Grade */
	switch ((val >> 6) & 0x3) {
	case 0: /* Commercial (0 to 95C) */
		data->temp_grade = "Commercial";
		data->temp_max = 95000;
		break;
	case 1: /* Extended Commercial (-20 to 105C) */
		data->temp_grade = "Extended Commercial";
		data->temp_max = 105000;
		break;
	case 2: /* Industrial (-40 to 105C) */
		data->temp_grade = "Industrial";
		data->temp_max = 105000;
		break;
	case 3: /* Automotive (-40 to 125C) */
		data->temp_grade = "Automotive";
		data->temp_max = 125000;
		break;
	}

	/*
	 * The maximum die temperature set to 20 C higher than
	 * IMX_TEMP_PASSIVE.
	 * Set the critical trip point at 5C under max
	 * Set the passive trip point at 10C under max (can change via sysfs)
	 */
	data->temp_critical = 1000 * 20 + data->temp_passive;
	data->temp_critical = data->temp_max - (1000 * 5);
	data->temp_passive = data->temp_max - (1000 * 10);

	return 0;
}
@@ -551,6 +572,11 @@ static int imx_thermal_probe(struct platform_device *pdev)
		return ret;
	}

	dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC"
		 " critical:%dC passive:%dC\n", data->temp_grade,
		 data->temp_max / 1000, data->temp_critical / 1000,
		 data->temp_passive / 1000);

	/* Enable measurements at ~ 10 Hz */
	regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ);
	measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */
+1 −1
Original line number Diff line number Diff line
@@ -964,7 +964,7 @@ void of_thermal_destroy_zones(void)

	np = of_find_node_by_name(NULL, "thermal-zones");
	if (!np) {
		pr_err("unable to find thermal zones\n");
		pr_debug("unable to find thermal zones\n");
		return;
	}

+7 −17
Original line number Diff line number Diff line
@@ -174,7 +174,6 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,
/**
 * pid_controller() - PID controller
 * @tz:	thermal zone we are operating in
 * @current_temp:	the current temperature in millicelsius
 * @control_temp:	the target temperature in millicelsius
 * @max_allocatable_power:	maximum allocatable power for this thermal zone
 *
@@ -191,7 +190,6 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,
 * Return: The power budget for the next period.
 */
static u32 pid_controller(struct thermal_zone_device *tz,
			  int current_temp,
			  int control_temp,
			  u32 max_allocatable_power)
{
@@ -211,7 +209,7 @@ static u32 pid_controller(struct thermal_zone_device *tz,
				       true);
	}

	err = control_temp - current_temp;
	err = control_temp - tz->temperature;
	err = int_to_frac(err);

	/* Calculate the proportional term */
@@ -332,7 +330,6 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors,
}

static int allocate_power(struct thermal_zone_device *tz,
			  int current_temp,
			  int control_temp)
{
	struct thermal_instance *instance;
@@ -418,8 +415,7 @@ static int allocate_power(struct thermal_zone_device *tz,
		i++;
	}

	power_range = pid_controller(tz, current_temp, control_temp,
				     max_allocatable_power);
	power_range = pid_controller(tz, control_temp, max_allocatable_power);

	divvy_up_power(weighted_req_power, max_power, num_actors,
		       total_weighted_req_power, power_range, granted_power,
@@ -444,8 +440,8 @@ static int allocate_power(struct thermal_zone_device *tz,
	trace_thermal_power_allocator(tz, req_power, total_req_power,
				      granted_power, total_granted_power,
				      num_actors, power_range,
				      max_allocatable_power, current_temp,
				      control_temp - current_temp);
				      max_allocatable_power, tz->temperature,
				      control_temp - tz->temperature);

	kfree(req_power);
unlock:
@@ -612,7 +608,7 @@ static void power_allocator_unbind(struct thermal_zone_device *tz)
static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
{
	int ret;
	int switch_on_temp, control_temp, current_temp;
	int switch_on_temp, control_temp;
	struct power_allocator_params *params = tz->governor_data;

	/*
@@ -622,15 +618,9 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
	if (trip != params->trip_max_desired_temperature)
		return 0;

	ret = thermal_zone_get_temp(tz, &current_temp);
	if (ret) {
		dev_warn(&tz->device, "Failed to get temperature: %d\n", ret);
		return ret;
	}

	ret = tz->ops->get_trip_temp(tz, params->trip_switch_on,
				     &switch_on_temp);
	if (!ret && (current_temp < switch_on_temp)) {
	if (!ret && (tz->temperature < switch_on_temp)) {
		tz->passive = 0;
		reset_pid_controller(params);
		allow_maximum_power(tz);
@@ -648,7 +638,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
		return ret;
	}

	return allocate_power(tz, current_temp, control_temp);
	return allocate_power(tz, control_temp);
}

static struct thermal_governor thermal_gov_power_allocator = {
Loading