From 925da4d7570316b140e55dbb3d49d0b406239aff Mon Sep 17 00:00:00 2001 From: Amit Kucheria Date: Mon, 10 Dec 2018 21:33:08 +0530 Subject: arm64: defconfig: Enable PMIC thermal QCOM_SPMI_ADC5 is required on 8998, SDM845 and QCS404. Compile SPMI_TEMP_ALARM into the kernel to ease testing. Signed-off-by: Amit Kucheria --- arch/arm64/configs/defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 4d583514258c..8466507d2e70 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -416,6 +416,7 @@ CONFIG_BRCMSTB_THERMAL=m CONFIG_EXYNOS_THERMAL=y CONFIG_TEGRA_BPMP_THERMAL=m CONFIG_QCOM_TSENS=y +CONFIG_QCOM_SPMI_TEMP_ALARM=y CONFIG_UNIPHIER_THERMAL=y CONFIG_WATCHDOG=y CONFIG_ARM_SP805_WATCHDOG=y @@ -704,6 +705,7 @@ CONFIG_EXTCON_USBC_CROS_EC=y CONFIG_MEMORY=y CONFIG_IIO=y CONFIG_EXYNOS_ADC=y +CONFIG_QCOM_SPMI_ADC5=y CONFIG_ROCKCHIP_SARADC=m CONFIG_IIO_CROS_EC_SENSORS_CORE=m CONFIG_IIO_CROS_EC_SENSORS=m -- cgit v1.2.3 From be2900d8e7ac9c12071a45dd923364e5e7ecba3d Mon Sep 17 00:00:00 2001 From: Amit Kucheria Date: Fri, 8 Mar 2019 12:53:02 +0530 Subject: arm64: dts: qcom: pms405: calibrate the VADC correctly Set the qcom,ratiometric property to make the VADC use the VDD reference (1.875V) and GND for channel calibration of the temperature channels instead of 1.25V. Allow a 200us delay between the AMUX configuration and ADC starting conversion using qcom,hw-settle-time as described in documentation. Fixes: 041b9a7b9fdb ("arm64: dts: pms405: Export PMIC temperature to thermal framework") Signed-off-by: Amit Kucheria --- arch/arm64/boot/dts/qcom/pms405.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/pms405.dtsi b/arch/arm64/boot/dts/qcom/pms405.dtsi index e8e186bc1ea7..a3d5db071774 100644 --- a/arch/arm64/boot/dts/qcom/pms405.dtsi +++ b/arch/arm64/boot/dts/qcom/pms405.dtsi @@ -110,16 +110,22 @@ xo_therm_100k_pu { reg = ; + qcom,ratiometric; + qcom,hw-settle-time = <200>; qcom,pre-scaling = <1 1>; }; amux_thm1_100k_pu { reg = ; + qcom,ratiometric; + qcom,hw-settle-time = <200>; qcom,pre-scaling = <1 1>; }; amux_thm3_100k_pu { reg = ; + qcom,ratiometric; + qcom,hw-settle-time = <200>; qcom,pre-scaling = <1 1>; }; }; -- cgit v1.2.3 From 26239487554bff1d3081bb6f7df58ab613d435de Mon Sep 17 00:00:00 2001 From: Amit Kucheria Date: Tue, 19 Mar 2019 23:47:12 +0530 Subject: arm64: dts: qcom: pms405: Rename adc outputs as per schematics The adc outputs shouldn't contain information about their configuration e.g. 100K pull-up, but just reflect the name of the signal in the schematics. Making them labels also allows us to overwrite their configuration in board-specific DTs. Sort them by order as used in adc5_chans_rev2, while we're at it. Signed-off-by: Amit Kucheria --- arch/arm64/boot/dts/qcom/pms405.dtsi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/pms405.dtsi b/arch/arm64/boot/dts/qcom/pms405.dtsi index a3d5db071774..14240fedd916 100644 --- a/arch/arm64/boot/dts/qcom/pms405.dtsi +++ b/arch/arm64/boot/dts/qcom/pms405.dtsi @@ -98,7 +98,7 @@ qcom,pre-scaling = <1 1>; }; - vph_pwr { + pon_1: vph_pwr { reg = ; qcom,pre-scaling = <1 3>; }; @@ -108,22 +108,22 @@ qcom,pre-scaling = <1 1>; }; - xo_therm_100k_pu { - reg = ; + pa_therm1: thermistor1 { + reg = ; qcom,ratiometric; qcom,hw-settle-time = <200>; qcom,pre-scaling = <1 1>; }; - amux_thm1_100k_pu { - reg = ; + pa_therm3: thermistor3 { + reg = ; qcom,ratiometric; qcom,hw-settle-time = <200>; qcom,pre-scaling = <1 1>; }; - amux_thm3_100k_pu { - reg = ; + xo_therm: xo_temp { + reg = ; qcom,ratiometric; qcom,hw-settle-time = <200>; qcom,pre-scaling = <1 1>; -- cgit v1.2.3 From acf124c6af8f361a4842c518c81da9456abcc26f Mon Sep 17 00:00:00 2001 From: Amit Kucheria Date: Mon, 8 Jul 2019 15:28:33 +0530 Subject: drivers: cpufreq: Initialize governors earlier Initialize cpufreq governors earlier so we can run at the highest frequencies sooner during boot (in case the bootloader programmed a conservative frequency) and conversely throttle back earlier too in case thermal mitigation is needed. Signed-off-by: Amit Kucheria --- drivers/cpufreq/cpufreq_conservative.c | 2 +- drivers/cpufreq/cpufreq_ondemand.c | 2 +- drivers/cpufreq/cpufreq_performance.c | 2 +- drivers/cpufreq/cpufreq_powersave.c | 2 +- drivers/cpufreq/cpufreq_userspace.c | 2 +- kernel/sched/cpufreq_schedutil.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index b66e81c06a57..737ff3b9c2c0 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c @@ -346,7 +346,7 @@ struct cpufreq_governor *cpufreq_default_governor(void) return CPU_FREQ_GOV_CONSERVATIVE; } -fs_initcall(cpufreq_gov_dbs_init); +core_initcall(cpufreq_gov_dbs_init); #else module_init(cpufreq_gov_dbs_init); #endif diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index dced033875bf..82a4d37ddecb 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -483,7 +483,7 @@ struct cpufreq_governor *cpufreq_default_governor(void) return CPU_FREQ_GOV_ONDEMAND; } -fs_initcall(cpufreq_gov_dbs_init); +core_initcall(cpufreq_gov_dbs_init); #else module_init(cpufreq_gov_dbs_init); #endif diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c index aaa04dfcacd9..def9afe0f5b8 100644 --- a/drivers/cpufreq/cpufreq_performance.c +++ b/drivers/cpufreq/cpufreq_performance.c @@ -50,5 +50,5 @@ MODULE_AUTHOR("Dominik Brodowski "); MODULE_DESCRIPTION("CPUfreq policy governor 'performance'"); MODULE_LICENSE("GPL"); -fs_initcall(cpufreq_gov_performance_init); +core_initcall(cpufreq_gov_performance_init); module_exit(cpufreq_gov_performance_exit); diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c index c143dc237d87..1ae66019eb83 100644 --- a/drivers/cpufreq/cpufreq_powersave.c +++ b/drivers/cpufreq/cpufreq_powersave.c @@ -43,7 +43,7 @@ struct cpufreq_governor *cpufreq_default_governor(void) return &cpufreq_gov_powersave; } -fs_initcall(cpufreq_gov_powersave_init); +core_initcall(cpufreq_gov_powersave_init); #else module_init(cpufreq_gov_powersave_init); #endif diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index cbd81c58cb8f..b43e7cd502c5 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c @@ -147,7 +147,7 @@ struct cpufreq_governor *cpufreq_default_governor(void) return &cpufreq_gov_userspace; } -fs_initcall(cpufreq_gov_userspace_init); +core_initcall(cpufreq_gov_userspace_init); #else module_init(cpufreq_gov_userspace_init); #endif diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 962cf343f798..4a0c5d55f36c 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -894,7 +894,7 @@ static int __init sugov_register(void) { return cpufreq_register_governor(&schedutil_gov); } -fs_initcall(sugov_register); +core_initcall(sugov_register); #ifdef CONFIG_ENERGY_MODEL extern bool sched_energy_update; -- cgit v1.2.3 From 52cce7fe47b9375c79fd0e99697e56c377438034 Mon Sep 17 00:00:00 2001 From: Amit Kucheria Date: Mon, 8 Jul 2019 15:32:46 +0530 Subject: drivers: cpufreq: Initialize platform drivers earlier Register platform drivers earlier now that the rest of the cpufreq infrastructure is initialised in core_initcall. Signed-off-by: Amit Kucheria --- drivers/cpufreq/cpufreq-dt-platdev.c | 2 +- drivers/cpufreq/qcom-cpufreq-hw.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c index 88e00683eaeb..682c64c2bf27 100644 --- a/drivers/cpufreq/cpufreq-dt-platdev.c +++ b/drivers/cpufreq/cpufreq-dt-platdev.c @@ -172,4 +172,4 @@ create_pdev: -1, data, sizeof(struct cpufreq_dt_platform_data))); } -device_initcall(cpufreq_dt_platdev_init); +core_initcall(cpufreq_dt_platdev_init); diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 4b0b50403901..eabcc2292a8a 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -327,7 +327,7 @@ static int __init qcom_cpufreq_hw_init(void) { return platform_driver_register(&qcom_cpufreq_hw_driver); } -device_initcall(qcom_cpufreq_hw_init); +core_initcall(qcom_cpufreq_hw_init); static void __exit qcom_cpufreq_hw_exit(void) { -- cgit v1.2.3 From a8cd626ccdff8a3c14388c4bc211f7f602a8d345 Mon Sep 17 00:00:00 2001 From: Amit Kucheria Date: Thu, 8 Feb 2018 17:03:21 +0530 Subject: drivers: thermal: Initialize thermal core earlier Modern devices have two contradictory boot requirements - boot as quickly as possible (which often means runs as fast as possible) while staying under the thermal envelope. Now that we've moved cpufreq initialisation and supported platform drivers to core_initcall, let us move the thermal framework initialization earlier too. However, netlink initialization happens only as part of fs_initcall so it has a userspace available. Initialize netlink events separately, later in the boot process. Originally-by: Lina Iyer Signed-off-by: Amit Kucheria --- drivers/thermal/thermal_core.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 46cfb7de4eb2..12242fdf0a0e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1462,6 +1462,8 @@ static struct genl_family thermal_event_genl_family __ro_after_init = { .n_mcgrps = ARRAY_SIZE(thermal_event_mcgrps), }; +static bool allow_netlink_events; + int thermal_generate_netlink_event(struct thermal_zone_device *tz, enum events event) { @@ -1476,6 +1478,9 @@ int thermal_generate_netlink_event(struct thermal_zone_device *tz, if (!tz) return -EINVAL; + if (!allow_netlink_events) + return -ENODEV; + /* allocate memory */ size = nla_total_size(sizeof(struct thermal_genl_event)) + nla_total_size(0); @@ -1527,16 +1532,18 @@ EXPORT_SYMBOL_GPL(thermal_generate_netlink_event); static int __init genetlink_init(void) { - return genl_register_family(&thermal_event_genl_family); -} + int err; -static void genetlink_exit(void) -{ - genl_unregister_family(&thermal_event_genl_family); + err = genl_register_family(&thermal_event_genl_family); + if (!err) + allow_netlink_events = true; + return err; } + #else /* !CONFIG_NET */ static inline int genetlink_init(void) { return 0; } -static inline void genetlink_exit(void) {} +static inline int thermal_generate_netlink_event(struct thermal_zone_device *tz, + enum events event) { return -ENODEV; } #endif /* !CONFIG_NET */ static int thermal_pm_notify(struct notifier_block *nb, @@ -1585,19 +1592,15 @@ static int __init thermal_init(void) mutex_init(&poweroff_lock); result = thermal_register_governors(); if (result) - goto error; + goto init_exit; result = class_register(&thermal_class); if (result) goto unregister_governors; - result = genetlink_init(); - if (result) - goto unregister_class; - result = of_parse_thermal_zones(); if (result) - goto exit_netlink; + goto exit_zone_parse; result = register_pm_notifier(&thermal_pm_nb); if (result) @@ -1606,13 +1609,11 @@ static int __init thermal_init(void) return 0; -exit_netlink: - genetlink_exit(); -unregister_class: +exit_zone_parse: class_unregister(&thermal_class); unregister_governors: thermal_unregister_governors(); -error: +init_exit: ida_destroy(&thermal_tz_ida); ida_destroy(&thermal_cdev_ida); mutex_destroy(&thermal_list_lock); @@ -1620,4 +1621,10 @@ error: mutex_destroy(&poweroff_lock); return result; } -fs_initcall(thermal_init); + +static int __init thermal_netlink_init(void) +{ + return genetlink_init(); +} +core_initcall(thermal_init); +fs_initcall(thermal_netlink_init); -- cgit v1.2.3