From 1a7c988619900b60c509dcebc23bc2c93270fc4b Mon Sep 17 00:00:00 2001 From: Punit Agrawal Date: Mon, 2 Jun 2014 17:39:47 +0100 Subject: thermal: scpi: Add support for SCPI based thermal sensor SCPI provides an interface to - * query the sensors in the system * query the value of these sensors Extend the SCPI protocol implementation to support these sensors. Building on these SCPI commands, integrate the thermal sensor "SENSOR_TEMP_SOC" with the linux thermal framework and create a SoC thermal zone using the of-thermal APIs. Signed-off-by: Punit Agrawal Signed-off-by: Jon Medhurst --- drivers/thermal/Kconfig | 8 ++++ drivers/thermal/Makefile | 1 + drivers/thermal/scpi-thermal.c | 90 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 drivers/thermal/scpi-thermal.c diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index e92e1dcb6e3f..ae9298c45a0c 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -182,6 +182,14 @@ config DB8500_CPUFREQ_COOLING bound cpufreq cooling device turns active to set CPU frequency low to cool down the CPU. +config SCPI_THERMAL + tristate "Temperature sensor on ARM SoC based on SCPI Firmware interface" + depends on ARM_SCPI_PROTOCOL + depends on OF + help + Support for the SCPI thermal sensor driver in the Linux thermal + framework. + config INTEL_POWERCLAMP tristate "Intel PowerClamp idle injection driver" depends on THERMAL diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index 71f8eef49c1c..a30486787b9f 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -26,5 +26,6 @@ obj-$(CONFIG_DOVE_THERMAL) += dove_thermal.o obj-$(CONFIG_DB8500_THERMAL) += db8500_thermal.o obj-$(CONFIG_ARMADA_THERMAL) += armada_thermal.o obj-$(CONFIG_DB8500_CPUFREQ_COOLING) += db8500_cpufreq_cooling.o +obj-$(CONFIG_SCPI_THERMAL) += scpi-thermal.o obj-$(CONFIG_INTEL_POWERCLAMP) += intel_powerclamp.o diff --git a/drivers/thermal/scpi-thermal.c b/drivers/thermal/scpi-thermal.c new file mode 100644 index 000000000000..241c6c0fd412 --- /dev/null +++ b/drivers/thermal/scpi-thermal.c @@ -0,0 +1,90 @@ +#include +#include +#include +#include +#include + +#define SOC_SENSOR "SENSOR_TEMP_SOC" + +struct scpi_sensor { + u16 sensor_id; + struct thermal_zone_device *tzd; +}; + +struct scpi_sensor scpi_temp_sensor; + +static int get_temp_value(void *data, long *temp) +{ + struct scpi_sensor *sensor = (struct scpi_sensor *)data; + u32 val; + int ret; + + ret = scpi_get_sensor_value(sensor->sensor_id, &val); + + if (!ret) + *temp = (unsigned long)val; + + return ret; +} + +static int scpi_thermal_probe(struct platform_device *pdev) +{ + struct scpi_sensor *sensor_data = &scpi_temp_sensor; + int sensor; + + platform_set_drvdata(pdev, sensor_data); + + if ((sensor = scpi_get_sensor(SOC_SENSOR)) < 0) { + dev_warn(&pdev->dev, "%s not found. ret=%d\n", SOC_SENSOR, sensor); + goto error; + } + + sensor_data->sensor_id = (u16)sensor; + dev_info(&pdev->dev, "Probed %s sensor. Id=%hu\n", SOC_SENSOR, sensor_data->sensor_id); + + sensor_data->tzd = thermal_zone_of_sensor_register(&pdev->dev, + sensor_data->sensor_id, + sensor_data, + get_temp_value, NULL); + + if (IS_ERR(sensor_data->tzd)) { + dev_warn(&pdev->dev, "Error registering sensor: %p\n", sensor_data->tzd); + return PTR_ERR(sensor_data->tzd); + } + + thermal_zone_device_update(sensor_data->tzd); + + return 0; + +error: + return -ENODEV; +} + +static int scpi_thermal_remove(struct platform_device *pdev) +{ + struct scpi_sensor *sensor = platform_get_drvdata(pdev); + + thermal_zone_device_unregister(sensor->tzd); + platform_set_drvdata(pdev, NULL); + + return 0; +} + +static struct of_device_id scpi_thermal_of_match[] = { + { .compatible = "arm,scpi-thermal" }, + {}, +}; +MODULE_DEVICE_TABLE(of, scpi_thermal_of_match); + +static struct platform_driver scpi_thermal_platdrv = { + .driver = { + .name = "scpi-thermal", + .owner = THIS_MODULE, + .of_match_table = scpi_thermal_of_match, + }, + .probe = scpi_thermal_probe, + .remove = scpi_thermal_remove, +}; +module_platform_driver(scpi_thermal_platdrv); + +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 681345e6a21c034249c71043c69fc6781296146e Mon Sep 17 00:00:00 2001 From: Punit Agrawal Date: Mon, 2 Jun 2014 18:21:07 +0100 Subject: thermal: scpi: Add support for cluster cooling devices Extend the SCPI sensor driver to register cluster cooling devices. Signed-off-by: Punit Agrawal Signed-off-by: Jon Medhurst --- drivers/thermal/scpi-thermal.c | 64 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/scpi-thermal.c b/drivers/thermal/scpi-thermal.c index 241c6c0fd412..0558e047629e 100644 --- a/drivers/thermal/scpi-thermal.c +++ b/drivers/thermal/scpi-thermal.c @@ -1,3 +1,6 @@ +#include +#include +#include #include #include #include @@ -6,9 +9,28 @@ #define SOC_SENSOR "SENSOR_TEMP_SOC" +enum cluster_type { + CLUSTER_BIG = 0, + CLUSTER_LITTLE, + NUM_CLUSTERS +}; + +struct cluster_power_coefficients { + int dyn_coeff; +} cluster_data[] = { + [CLUSTER_BIG] = { + .dyn_coeff = 530, + }, + [CLUSTER_LITTLE] = { + .dyn_coeff = 140, + }, +}; + struct scpi_sensor { u16 sensor_id; struct thermal_zone_device *tzd; + struct cpumask cluster[NUM_CLUSTERS]; + struct thermal_cooling_device *cdevs[NUM_CLUSTERS]; }; struct scpi_sensor scpi_temp_sensor; @@ -30,10 +52,50 @@ static int get_temp_value(void *data, long *temp) static int scpi_thermal_probe(struct platform_device *pdev) { struct scpi_sensor *sensor_data = &scpi_temp_sensor; - int sensor; + struct device_node *np; + int sensor, cpu; + int i; + + if (!cpufreq_frequency_get_table(0)) { + dev_info(&pdev->dev, + "Frequency table not initialized. Deferring probe...\n"); + return -EPROBE_DEFER; + } platform_set_drvdata(pdev, sensor_data); + for_each_possible_cpu(cpu) { + int cluster_id = topology_physical_package_id(cpu); + if (cluster_id > NUM_CLUSTERS) { + pr_warn("Cluster id: %d > %d\n", cluster_id, NUM_CLUSTERS); + goto error; + } + + cpumask_set_cpu(cpu, &sensor_data->cluster[cluster_id]); + } + + for (i = 0; i < NUM_CLUSTERS; i++) { + char node[16]; + enum cluster_type cluster = + topology_physical_package_id(cpumask_any(&sensor_data->cluster[i])); + + snprintf(node, 16, "cluster%d", i); + np = of_find_node_by_name(NULL, node); + + if (!np) + dev_info(&pdev->dev, "Node not found: %s\n", node); + + sensor_data->cdevs[i] = + of_cpufreq_power_cooling_register(np, + &sensor_data->cluster[i], + cluster_data[cluster].dyn_coeff, + get_static_power); + + if (IS_ERR(sensor_data->cdevs[i])) + dev_warn(&pdev->dev, + "Error registering cooling device: %d\n", i); + } + if ((sensor = scpi_get_sensor(SOC_SENSOR)) < 0) { dev_warn(&pdev->dev, "%s not found. ret=%d\n", SOC_SENSOR, sensor); goto error; -- cgit v1.2.3 From 5931af405cf8cad043095922285d858a07c6c88b Mon Sep 17 00:00:00 2001 From: Punit Agrawal Date: Mon, 2 Jun 2014 18:23:26 +0100 Subject: juno: dt: describe thermal sensor and cooling devices Signed-off-by: Jon Medhurst --- arch/arm64/boot/dts/juno.dts | 49 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/juno.dts b/arch/arm64/boot/dts/juno.dts index b8baba186b1e..07d1ff0eae2f 100644 --- a/arch/arm64/boot/dts/juno.dts +++ b/arch/arm64/boot/dts/juno.dts @@ -9,6 +9,7 @@ /dts-v1/; #include +#include / { model = "ARM Juno development board (r0)"; @@ -35,7 +36,9 @@ #size-cells = <0>; cpu-map { - cluster0 { + cluster0: cluster0 { + #cooling-cells = <2>; /* min followed by max */ + core0 { cpu = <&A57_0>; }; @@ -44,7 +47,9 @@ }; }; - cluster1 { + cluster1: cluster1 { + #cooling-cells = <2>; /* min followed by max */ + core0 { cpu = <&A53_0>; }; @@ -140,6 +145,46 @@ ; }; + scpi_sensor0: scpi-sensor@0 { + compatible = "arm,scpi-thermal"; + #thermal-sensor-cells = <1>; + }; + + thermal-zones { + soc_thermal { + polling-delay = <1000>; + polling-delay-passive = <100>; + sustainable-power = <2500>; + + thermal-sensors = <&scpi_sensor0 3>; + + trips { + threshold: trip-point@0 { + temperature = <55000>; + hysteresis = <1000>; + type = "passive"; + }; + target: trip-point@1 { + temperature = <65000>; + hysteresis = <1000>; + type = "passive"; + }; + }; + + cooling-maps { + map0 { + trip = <&target>; + cooling-device = <&cluster0 0 4>; + }; + map1 { + trip = <&target>; + cooling-device = <&cluster1 0 4>; + }; + + }; + }; + }; + /include/ "juno-clocks.dtsi" dma@7ff00000 { -- cgit v1.2.3 From da4189f552b103611003a61dc6ae241f9f35213d Mon Sep 17 00:00:00 2001 From: Punit Agrawal Date: Mon, 14 Jul 2014 16:20:36 +0100 Subject: thermal: scpi: Add static power model for juno Introduce a static power model for Juno. Signed-off-by: Punit Agrawal Signed-off-by: Jon Medhurst --- drivers/thermal/scpi-thermal.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/thermal/scpi-thermal.c b/drivers/thermal/scpi-thermal.c index 0558e047629e..323bc885e02b 100644 --- a/drivers/thermal/scpi-thermal.c +++ b/drivers/thermal/scpi-thermal.c @@ -17,12 +17,18 @@ enum cluster_type { struct cluster_power_coefficients { int dyn_coeff; + int static_coeff; + int cache_static_coeff; } cluster_data[] = { [CLUSTER_BIG] = { .dyn_coeff = 530, + .static_coeff = 103, /* 75 mW @ 85C/0.9V */ + .cache_static_coeff = 88, /* 64 mW @ 85C/0.9V */ }, [CLUSTER_LITTLE] = { .dyn_coeff = 140, + .static_coeff = 36, /* 26 mW @ 85C/0.9V */ + .cache_static_coeff = 73, /* 53 mW @ 85C/0.9V */ }, }; @@ -35,6 +41,62 @@ struct scpi_sensor { struct scpi_sensor scpi_temp_sensor; +static unsigned long get_temperature_scale(unsigned long temp) +{ + int i, t_exp = 1, t_scale = 0; + int coeff[] = { 32000, 4700, -80, 2 }; /* * 1E6 */ + + for (i = 0; i < 4; i++) { + t_scale += coeff[i] * t_exp; + t_exp *= temp; + } + + return t_scale / 1000; /* the value returned needs to be /1E3 */ +} + +static unsigned long get_voltage_scale(unsigned long u_volt) +{ + unsigned long m_volt = u_volt / 1000; + unsigned long v_scale; + + v_scale = m_volt * m_volt * m_volt; /* = (m_V^3) / (900 ^ 3) = */ + + return v_scale / 1000000; /* the value returned needs to be /(1E3) */ +} + +/* voltage in uV */ +static int get_static_power(cpumask_t *cpumask, int interval, + unsigned long u_volt, u32 *static_power) +{ + unsigned long temperature, t_scale, v_scale; + u32 cpu_coeff; + int nr_cpus = cpumask_weight(cpumask); + enum cluster_type cluster = + topology_physical_package_id(cpumask_any(cpumask)); + + if (!scpi_temp_sensor.tzd) + return -ENODEV; + + cpu_coeff = cluster_data[cluster].static_coeff; + + /* temperature in mC */ + temperature = scpi_temp_sensor.tzd->temperature / 1000; + + t_scale = get_temperature_scale(temperature); + v_scale = get_voltage_scale(u_volt); + + *static_power = nr_cpus * (cpu_coeff * t_scale * v_scale) / 1000000; + + if (nr_cpus) { + u32 cache_coeff = cluster_data[cluster].cache_static_coeff; + + /* cache leakage */ + *static_power += (cache_coeff * v_scale * t_scale) / 1000000; + } + + return 0; +} + static int get_temp_value(void *data, long *temp) { struct scpi_sensor *sensor = (struct scpi_sensor *)data; -- cgit v1.2.3 From f97ec60e0d05aa1373c67f4562a04f4f969559b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98rjan=20Eide?= Date: Tue, 15 Jul 2014 16:02:04 +0200 Subject: juno: dt: Map gpu to thermal zone Signed-off-by: Jon Medhurst --- arch/arm64/boot/dts/juno.dts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/juno.dts b/arch/arm64/boot/dts/juno.dts index 07d1ff0eae2f..19b58c968745 100644 --- a/arch/arm64/boot/dts/juno.dts +++ b/arch/arm64/boot/dts/juno.dts @@ -180,7 +180,10 @@ trip = <&target>; cooling-device = <&cluster1 0 4>; }; - + map2 { + trip = <&target>; + cooling-device = <&gpu 0 4>; + }; }; }; }; @@ -264,8 +267,9 @@ clock-names = "apb_pclk"; }; - gpu@0x2d000000 { + gpu: gpu@0x2d000000 { compatible = "arm,malit6xx", "arm,mali"; + #cooling-cells = <2>; /* min followed by max */ reg = <0x0 0x2d000000 0x0 0x4000>; interrupts = <0 33 4>, <0 34 4>, <0 32 4>; interrupt-names = "JOB", "MMU", "GPU"; -- cgit v1.2.3 From f51c0896af7fb06d89c61665f32281c935636e4e Mon Sep 17 00:00:00 2001 From: Punit Agrawal Date: Mon, 21 Jul 2014 14:49:36 +0100 Subject: juno: dt: Add weights for all the actors Signed-off-by: Jon Medhurst --- arch/arm64/boot/dts/juno.dts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/boot/dts/juno.dts b/arch/arm64/boot/dts/juno.dts index 19b58c968745..bc6071563761 100644 --- a/arch/arm64/boot/dts/juno.dts +++ b/arch/arm64/boot/dts/juno.dts @@ -175,14 +175,17 @@ map0 { trip = <&target>; cooling-device = <&cluster0 0 4>; + contribution = <1024>; }; map1 { trip = <&target>; cooling-device = <&cluster1 0 4>; + contribution = <2048>; }; map2 { trip = <&target>; cooling-device = <&gpu 0 4>; + contribution = <1024>; }; }; }; -- cgit v1.2.3 From 10305865374b771f82308a5056de043f682b5604 Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Fri, 1 Aug 2014 17:39:44 +0100 Subject: thermal: scpi: smooth the temperature reading Signed-off-by: Jon Medhurst --- drivers/thermal/scpi-thermal.c | 43 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/scpi-thermal.c b/drivers/thermal/scpi-thermal.c index 323bc885e02b..f2d65e11c140 100644 --- a/drivers/thermal/scpi-thermal.c +++ b/drivers/thermal/scpi-thermal.c @@ -34,6 +34,8 @@ struct cluster_power_coefficients { struct scpi_sensor { u16 sensor_id; + unsigned long prev_temp; + u32 alpha; struct thermal_zone_device *tzd; struct cpumask cluster[NUM_CLUSTERS]; struct thermal_cooling_device *cdevs[NUM_CLUSTERS]; @@ -41,6 +43,23 @@ struct scpi_sensor { struct scpi_sensor scpi_temp_sensor; +#define FRAC_BITS 10 +#define int_to_frac(x) ((x) << FRAC_BITS) +#define frac_to_int(x) ((x) >> FRAC_BITS) + +/** + * mul_frac() - multiply two fixed-point numbers + * @x: first multiplicand + * @y: second multiplicand + * + * Return: the result of multiplying two fixed-point numbers. The + * result is also a fixed-point number. + */ +static inline s64 mul_frac(s64 x, s64 y) +{ + return (x * y) >> FRAC_BITS; +} + static unsigned long get_temperature_scale(unsigned long temp) { int i, t_exp = 1, t_scale = 0; @@ -102,13 +121,22 @@ static int get_temp_value(void *data, long *temp) struct scpi_sensor *sensor = (struct scpi_sensor *)data; u32 val; int ret; + unsigned long est_temp; ret = scpi_get_sensor_value(sensor->sensor_id, &val); + if (ret) + return ret; + + if (!sensor->prev_temp) + sensor->prev_temp = val; - if (!ret) - *temp = (unsigned long)val; + est_temp = mul_frac(sensor->alpha, val) + + mul_frac((int_to_frac(1) - sensor->alpha), sensor->prev_temp); - return ret; + sensor->prev_temp = est_temp; + *temp = est_temp; + + return 0; } static int scpi_thermal_probe(struct platform_device *pdev) @@ -166,6 +194,15 @@ static int scpi_thermal_probe(struct platform_device *pdev) sensor_data->sensor_id = (u16)sensor; dev_info(&pdev->dev, "Probed %s sensor. Id=%hu\n", SOC_SENSOR, sensor_data->sensor_id); + /* + * alpha ~= 2 / (N + 1) with N the window of a rolling mean We + * use 8-bit fixed point arithmetic. For a rolling average of + * window 20, alpha = 2 / (20 + 1) ~= 0.09523809523809523 . + * In 8-bit fixed point arigthmetic, 0.09523809523809523 * 256 + * ~= 24 + */ + sensor_data->alpha = 24; + sensor_data->tzd = thermal_zone_of_sensor_register(&pdev->dev, sensor_data->sensor_id, sensor_data, -- cgit v1.2.3 From 68efd5cb5d884d95eb16046741c14bcf465afd59 Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Fri, 1 Aug 2014 17:45:47 +0100 Subject: thermal: scpi: add debugfs entry for alpha Signed-off-by: Jon Medhurst --- drivers/thermal/scpi-thermal.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/thermal/scpi-thermal.c b/drivers/thermal/scpi-thermal.c index f2d65e11c140..138c85dd2041 100644 --- a/drivers/thermal/scpi-thermal.c +++ b/drivers/thermal/scpi-thermal.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -139,6 +140,24 @@ static int get_temp_value(void *data, long *temp) return 0; } +static void update_debugfs(struct scpi_sensor *sensor_data) +{ + struct dentry *dentry_f, *filter_d; + + filter_d = debugfs_create_dir("thermal_lpf_filter", NULL); + if (IS_ERR_OR_NULL(filter_d)) { + pr_warning("unable to create debugfs directory for the LPF filter\n"); + return; + } + + dentry_f = debugfs_create_u32("alpha", S_IWUSR | S_IRUGO, filter_d, + &sensor_data->alpha); + if (IS_ERR_OR_NULL(dentry_f)) { + pr_warn("Unable to create debugfsfile: alpha\n"); + return; + } +} + static int scpi_thermal_probe(struct platform_device *pdev) { struct scpi_sensor *sensor_data = &scpi_temp_sensor; @@ -213,6 +232,8 @@ static int scpi_thermal_probe(struct platform_device *pdev) return PTR_ERR(sensor_data->tzd); } + update_debugfs(sensor_data); + thermal_zone_device_update(sensor_data->tzd); return 0; -- cgit v1.2.3 From c6f007d059bd07e39b022cedbc5dc25b40957079 Mon Sep 17 00:00:00 2001 From: Jon Medhurst Date: Fri, 19 Sep 2014 09:06:33 -0700 Subject: juno: Enable devfreq and thermal configs for IPA Signed-off-by: Jon Medhurst --- linaro/configs/vexpress64.conf | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/linaro/configs/vexpress64.conf b/linaro/configs/vexpress64.conf index c9b66a198586..ce40c865a498 100644 --- a/linaro/configs/vexpress64.conf +++ b/linaro/configs/vexpress64.conf @@ -53,3 +53,14 @@ CONFIG_ARM_BIG_LITTLE_CPUFREQ=y CONFIG_ARM_DT_BL_CPUFREQ=y CONFIG_ARM64_CPUIDLE=y CONFIG_ARM64_CRYPTO=y +CONFIG_THERMAL=y +CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR=y +CONFIG_THERMAL_GOV_USER_SPACE=y +CONFIG_CPU_THERMAL=y +CONFIG_PM_DEVFREQ=y +CONFIG_DEVFREQ_THERMAL=y +CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y +CONFIG_DEVFREQ_GOV_PERFORMANCE=y +CONFIG_SCPI_THERMAL=y +CONFIG_MALI_DEVFREQ=y +CONFIG_THERMAL_WRITABLE_TRIPS=y -- cgit v1.2.3 From f2935e4f10dbf4313f6cacafa3dadf0b23148e9d Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Thu, 5 Mar 2015 16:38:27 +0000 Subject: thermal: scpi: create a thermal zone for the gpu The GPU static power model needs a thermal zone to know the current temperature of the GPU. Provide a "gpu" thermal zone so that it can query it. Signed-off-by: Javi Merino Signed-off-by: Jon Medhurst --- drivers/thermal/scpi-thermal.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/thermal/scpi-thermal.c b/drivers/thermal/scpi-thermal.c index 138c85dd2041..f68c9ce5552e 100644 --- a/drivers/thermal/scpi-thermal.c +++ b/drivers/thermal/scpi-thermal.c @@ -38,6 +38,7 @@ struct scpi_sensor { unsigned long prev_temp; u32 alpha; struct thermal_zone_device *tzd; + struct thermal_zone_device *gpu_tzd; struct cpumask cluster[NUM_CLUSTERS]; struct thermal_cooling_device *cdevs[NUM_CLUSTERS]; }; @@ -140,6 +141,15 @@ static int get_temp_value(void *data, long *temp) return 0; } +static int get_temp_for_gpu(struct thermal_zone_device *tz, unsigned long *temp) +{ + struct scpi_sensor *sensor = (struct scpi_sensor *)tz->devdata; + + *temp = sensor->tzd->temperature; + + return 0; +} + static void update_debugfs(struct scpi_sensor *sensor_data) { struct dentry *dentry_f, *filter_d; @@ -158,6 +168,14 @@ static void update_debugfs(struct scpi_sensor *sensor_data) } } +static struct thermal_zone_device_ops gpu_dummy_tz_ops = { + .get_temp = get_temp_for_gpu, +}; + +static struct thermal_zone_params gpu_dummy_tzp = { + .governor_name = "user_space", +}; + static int scpi_thermal_probe(struct platform_device *pdev) { struct scpi_sensor *sensor_data = &scpi_temp_sensor; @@ -232,6 +250,19 @@ static int scpi_thermal_probe(struct platform_device *pdev) return PTR_ERR(sensor_data->tzd); } + sensor_data->gpu_tzd = thermal_zone_device_register("gpu", 0, 0, + sensor_data, + &gpu_dummy_tz_ops, + &gpu_dummy_tzp, + 0, 0); + if (IS_ERR(sensor_data->gpu_tzd)) { + int ret = PTR_ERR(sensor_data->gpu_tzd); + + dev_warn(&pdev->dev, "Error register gpu thermal zone: %d\n", + ret); + return ret; + } + update_debugfs(sensor_data); thermal_zone_device_update(sensor_data->tzd); -- cgit v1.2.3 From 3a2859d44938473bca16ab5b09e4db2d5392fcff Mon Sep 17 00:00:00 2001 From: Jon Medhurst Date: Tue, 21 Apr 2015 17:34:35 +0100 Subject: thermal: scpi: Update driver for new scpi interface Signed-off-by: Jon Medhurst --- drivers/thermal/scpi-thermal.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/scpi-thermal.c b/drivers/thermal/scpi-thermal.c index f68c9ce5552e..41eb908e4b70 100644 --- a/drivers/thermal/scpi-thermal.c +++ b/drivers/thermal/scpi-thermal.c @@ -43,6 +43,7 @@ struct scpi_sensor { struct thermal_cooling_device *cdevs[NUM_CLUSTERS]; }; +static struct scpi_ops *scpi_ops; struct scpi_sensor scpi_temp_sensor; #define FRAC_BITS 10 @@ -125,7 +126,7 @@ static int get_temp_value(void *data, long *temp) int ret; unsigned long est_temp; - ret = scpi_get_sensor_value(sensor->sensor_id, &val); + ret = scpi_ops->sensor_get_value(sensor->sensor_id, &val); if (ret) return ret; @@ -189,6 +190,10 @@ static int scpi_thermal_probe(struct platform_device *pdev) return -EPROBE_DEFER; } + scpi_ops = get_scpi_ops(); + if (!scpi_ops) + return -EIO; + platform_set_drvdata(pdev, sensor_data); for_each_possible_cpu(cpu) { @@ -223,7 +228,7 @@ static int scpi_thermal_probe(struct platform_device *pdev) "Error registering cooling device: %d\n", i); } - if ((sensor = scpi_get_sensor(SOC_SENSOR)) < 0) { + if ((sensor = scpi_ops->sensor_get_id(SOC_SENSOR)) < 0) { dev_warn(&pdev->dev, "%s not found. ret=%d\n", SOC_SENSOR, sensor); goto error; } -- cgit v1.2.3