mirror of https://gitee.com/openkylin/linux.git
thermal: imx: fix for dependency on cpu-freq
The thermal driver is a standalone driver for monitoring SoC temperature by enabling thermal sensor, so it can be enabled even when CONFIG_CPU_FREQ is NOT set. So remove the dependency with CPU_THERMAL. Introduce dummy function of legacy cooling register/unregister to make thermal driver probe successfully when CONFIG_CPU_FREQ is NOT set. Signed-off-by: Anson Huang <Anson.Huang@nxp.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
This commit is contained in:
parent
4ab248b3b1
commit
c589c56671
|
@ -212,7 +212,7 @@ config HISI_THERMAL
|
||||||
|
|
||||||
config IMX_THERMAL
|
config IMX_THERMAL
|
||||||
tristate "Temperature sensor driver for Freescale i.MX SoCs"
|
tristate "Temperature sensor driver for Freescale i.MX SoCs"
|
||||||
depends on (ARCH_MXC && CPU_THERMAL) || COMPILE_TEST
|
depends on ARCH_MXC || COMPILE_TEST
|
||||||
depends on NVMEM || !NVMEM
|
depends on NVMEM || !NVMEM
|
||||||
depends on MFD_SYSCON
|
depends on MFD_SYSCON
|
||||||
depends on OF
|
depends on OF
|
||||||
|
|
|
@ -648,15 +648,24 @@ static const struct of_device_id of_imx_thermal_match[] = {
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
|
MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CPU_FREQ
|
||||||
/*
|
/*
|
||||||
* Create cooling device in case no #cooling-cells property is available in
|
* Create cooling device in case no #cooling-cells property is available in
|
||||||
* CPU node
|
* CPU node
|
||||||
*/
|
*/
|
||||||
static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
|
static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
|
||||||
{
|
{
|
||||||
struct device_node *np = of_get_cpu_node(data->policy->cpu, NULL);
|
struct device_node *np;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
data->policy = cpufreq_cpu_get(0);
|
||||||
|
if (!data->policy) {
|
||||||
|
pr_debug("%s: CPUFreq policy not found\n", __func__);
|
||||||
|
return -EPROBE_DEFER;
|
||||||
|
}
|
||||||
|
|
||||||
|
np = of_get_cpu_node(data->policy->cpu, NULL);
|
||||||
|
|
||||||
if (!np || !of_find_property(np, "#cooling-cells", NULL)) {
|
if (!np || !of_find_property(np, "#cooling-cells", NULL)) {
|
||||||
data->cdev = cpufreq_cooling_register(data->policy);
|
data->cdev = cpufreq_cooling_register(data->policy);
|
||||||
if (IS_ERR(data->cdev)) {
|
if (IS_ERR(data->cdev)) {
|
||||||
|
@ -669,6 +678,24 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data *data)
|
||||||
|
{
|
||||||
|
cpufreq_cooling_unregister(data->cdev);
|
||||||
|
cpufreq_cpu_put(data->policy);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static inline int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data *data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int imx_thermal_probe(struct platform_device *pdev)
|
static int imx_thermal_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct imx_thermal_data *data;
|
struct imx_thermal_data *data;
|
||||||
|
@ -743,14 +770,11 @@ static int imx_thermal_probe(struct platform_device *pdev)
|
||||||
regmap_write(map, data->socdata->sensor_ctrl + REG_SET,
|
regmap_write(map, data->socdata->sensor_ctrl + REG_SET,
|
||||||
data->socdata->power_down_mask);
|
data->socdata->power_down_mask);
|
||||||
|
|
||||||
data->policy = cpufreq_cpu_get(0);
|
|
||||||
if (!data->policy) {
|
|
||||||
pr_debug("%s: CPUFreq policy not found\n", __func__);
|
|
||||||
return -EPROBE_DEFER;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = imx_thermal_register_legacy_cooling(data);
|
ret = imx_thermal_register_legacy_cooling(data);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
if (ret == -EPROBE_DEFER)
|
||||||
|
return ret;
|
||||||
|
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
"failed to register cpufreq cooling device: %d\n", ret);
|
"failed to register cpufreq cooling device: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -762,7 +786,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
|
||||||
if (ret != -EPROBE_DEFER)
|
if (ret != -EPROBE_DEFER)
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
"failed to get thermal clk: %d\n", ret);
|
"failed to get thermal clk: %d\n", ret);
|
||||||
goto cpufreq_put;
|
goto legacy_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -775,7 +799,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
|
||||||
ret = clk_prepare_enable(data->thermal_clk);
|
ret = clk_prepare_enable(data->thermal_clk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
|
dev_err(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
|
||||||
goto cpufreq_put;
|
goto legacy_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->tz = thermal_zone_device_register("imx_thermal_zone",
|
data->tz = thermal_zone_device_register("imx_thermal_zone",
|
||||||
|
@ -829,9 +853,8 @@ static int imx_thermal_probe(struct platform_device *pdev)
|
||||||
thermal_zone_device_unregister(data->tz);
|
thermal_zone_device_unregister(data->tz);
|
||||||
clk_disable:
|
clk_disable:
|
||||||
clk_disable_unprepare(data->thermal_clk);
|
clk_disable_unprepare(data->thermal_clk);
|
||||||
cpufreq_put:
|
legacy_cleanup:
|
||||||
cpufreq_cooling_unregister(data->cdev);
|
imx_thermal_unregister_legacy_cooling(data);
|
||||||
cpufreq_cpu_put(data->policy);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue