Loading Documentation/devicetree/bindings/thermal/tsens.txt +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ Required properties: should be "qcom,sdm630-tsens" for 630 TSENS driver. should be "qcom,sdm845-tsens" for SDM845 TSENS driver. should be "qcom,tsens24xx" for 2.4 TSENS controller. should be "qcom,msm8937-tsens" for 8937 TSENS driver. The compatible property is used to identify the respective controller to use for the corresponding SoC. - reg : offset and length of the TSENS registers with associated property in reg-names Loading arch/arm64/boot/dts/qcom/msm8937.dtsi +168 −0 Original line number Diff line number Diff line Loading @@ -235,6 +235,174 @@ qcom,pipe-attr-ee; }; thermal_zones: thermal-zones { aoss0-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-governor = "user_space"; thermal-sensors = <&tsens0 0>; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; mdm-core-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-governor = "user_space"; thermal-sensors = <&tsens0 1>; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; mdss-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-governor = "user_space"; thermal-sensors = <&tsens0 2>; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; camera-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-governor = "user_space"; thermal-sensors = <&tsens0 3>; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; cpuss-0-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 4>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; apc1_cpu1-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 5>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; apc1_cpu2-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 6>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; apc1_cpu3-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 7>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; apc1_cpu4-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 8>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; apc0_cpu0-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 9>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; gpu0-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 10>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; }; tsens0: tsens@4a8000 { compatible = "qcom,msm8937-tsens"; reg = <0x4a8000 0x1000>, <0x4a9000 0x1000>, <0xa4000 0x1000>; reg-names = "tsens_srot_physical", "tsens_tm_physical", "tsens_eeprom_physical"; interrupts = <0 184 0>; interrupt-names = "tsens-upper-lower"; #thermal-sensor-cells = <1>; }; slim_msm: slim@c140000{ cell-index = <1>; compatible = "qcom,slim-ngd"; Loading drivers/thermal/Makefile +1 −1 Original line number Diff line number Diff line Loading @@ -58,4 +58,4 @@ obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o obj-$(CONFIG_THERMAL_QPNP_ADC_TM) += qpnp-adc-tm.o obj-$(CONFIG_THERMAL_TSENS) += msm-tsens.o tsens2xxx.o tsens-dbg.o tsens-mtc.o obj-$(CONFIG_THERMAL_TSENS) += msm-tsens.o tsens2xxx.o tsens-dbg.o tsens-mtc.o tsens1xxx.o drivers/thermal/msm-tsens.c +31 −2 Original line number Diff line number Diff line /* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -49,6 +49,11 @@ static int tsens_init(struct tsens_device *tmdev) return tmdev->ops->hw_init(tmdev); } static int tsens_calib(struct tsens_device *tmdev) { return tmdev->ops->calibrate(tmdev); } static int tsens_register_interrupts(struct tsens_device *tmdev) { if (tmdev->ops->interrupts_reg) Loading Loading @@ -82,6 +87,9 @@ static const struct of_device_id tsens_table[] = { { .compatible = "qcom,tsens24xx", .data = &data_tsens24xx, }, { .compatible = "qcom,msm8937-tsens", .data = &data_tsens14xx, }, {} }; MODULE_DEVICE_TABLE(of, tsens_table); Loading @@ -97,6 +105,7 @@ static int get_device_tree_data(struct platform_device *pdev, struct device_node *of_node = pdev->dev.of_node; const struct of_device_id *id; const struct tsens_data *data; int rc = 0; struct resource *res_tsens_mem; if (!of_match_node(tsens_table, of_node)) { Loading Loading @@ -150,7 +159,27 @@ static int get_device_tree_data(struct platform_device *pdev, return PTR_ERR(tmdev->tsens_tm_addr); } return 0; /* TSENS eeprom register region */ res_tsens_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tsens_eeprom_physical"); if (!res_tsens_mem) { pr_debug("Could not get tsens physical address resource\n"); } else { tmdev->tsens_calib_addr = devm_ioremap_resource(&pdev->dev, res_tsens_mem); if (IS_ERR(tmdev->tsens_calib_addr)) { dev_err(&pdev->dev, "Failed to IO map TSENS EEPROM registers.\n"); rc = PTR_ERR(tmdev->tsens_calib_addr); } else { rc = tsens_calib(tmdev); if (rc) { pr_err("Error initializing TSENS controller\n"); return rc; } } } return rc; } static int tsens_thermal_zone_register(struct tsens_device *tmdev) Loading drivers/thermal/tsens.h +16 −3 Original line number Diff line number Diff line /* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -23,10 +23,15 @@ #define DEBUG_SIZE 10 #define TSENS_MAX_SENSORS 16 #define TSENS_1x_MAX_SENSORS 11 #define TSENS_CONTROLLER_ID(n) (n) #define TSENS_CTRL_ADDR(n) (n) #define TSENS_TM_SN_STATUS(n) ((n) + 0xa0) #define ONE_PT_CALIB 0x1 #define ONE_PT_CALIB2 0x2 #define TWO_PT_CALIB 0x3 enum tsens_dbg_type { TSENS_DBG_POLL, TSENS_DBG_LOG_TEMP_READS, Loading Loading @@ -70,6 +75,8 @@ struct tsens_context { int high_temp; int low_temp; int crit_temp; int high_adc_code; int low_adc_code; }; struct tsens_sensor { Loading @@ -79,6 +86,8 @@ struct tsens_sensor { u32 id; const char *sensor_name; struct tsens_context thr_state; int offset; int slope; }; /** Loading @@ -93,6 +102,7 @@ struct tsens_ops { int (*interrupts_reg)(struct tsens_device *); int (*dbg)(struct tsens_device *, u32, u32, int *); int (*sensor_en)(struct tsens_device *, u32); int (*calibrate)(struct tsens_device *); }; struct tsens_irqs { Loading @@ -116,14 +126,15 @@ struct tsens_data { bool wd_bark; u32 wd_bark_mask; bool mtc; bool valid_status_check; }; struct tsens_mtc_sysfs { uint32_t zone_log; u32 zone_log; int zone_mtc; int th1; int th2; uint32_t zone_hist; u32 zone_hist; }; struct tsens_device { Loading @@ -134,6 +145,7 @@ struct tsens_device { struct regmap_field *status_field; void __iomem *tsens_srot_addr; void __iomem *tsens_tm_addr; void __iomem *tsens_calib_addr; const struct tsens_ops *ops; struct tsens_dbg_context tsens_dbg; spinlock_t tsens_crit_lock; Loading @@ -144,6 +156,7 @@ struct tsens_device { }; extern const struct tsens_data data_tsens2xxx, data_tsens23xx, data_tsens24xx; extern const struct tsens_data data_tsens14xx; extern struct list_head tsens_device_list; #endif /* __QCOM_TSENS_H__ */ Loading
Documentation/devicetree/bindings/thermal/tsens.txt +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ Required properties: should be "qcom,sdm630-tsens" for 630 TSENS driver. should be "qcom,sdm845-tsens" for SDM845 TSENS driver. should be "qcom,tsens24xx" for 2.4 TSENS controller. should be "qcom,msm8937-tsens" for 8937 TSENS driver. The compatible property is used to identify the respective controller to use for the corresponding SoC. - reg : offset and length of the TSENS registers with associated property in reg-names Loading
arch/arm64/boot/dts/qcom/msm8937.dtsi +168 −0 Original line number Diff line number Diff line Loading @@ -235,6 +235,174 @@ qcom,pipe-attr-ee; }; thermal_zones: thermal-zones { aoss0-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-governor = "user_space"; thermal-sensors = <&tsens0 0>; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; mdm-core-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-governor = "user_space"; thermal-sensors = <&tsens0 1>; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; mdss-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-governor = "user_space"; thermal-sensors = <&tsens0 2>; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; camera-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-governor = "user_space"; thermal-sensors = <&tsens0 3>; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; cpuss-0-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 4>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; apc1_cpu1-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 5>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; apc1_cpu2-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 6>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; apc1_cpu3-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 7>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; apc1_cpu4-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 8>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; apc0_cpu0-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 9>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; gpu0-usr { polling-delay-passive = <0>; polling-delay = <0>; thermal-sensors = <&tsens0 10>; thermal-governor = "user_space"; trips { active-config0 { temperature = <125000>; hysteresis = <1000>; type = "passive"; }; }; }; }; tsens0: tsens@4a8000 { compatible = "qcom,msm8937-tsens"; reg = <0x4a8000 0x1000>, <0x4a9000 0x1000>, <0xa4000 0x1000>; reg-names = "tsens_srot_physical", "tsens_tm_physical", "tsens_eeprom_physical"; interrupts = <0 184 0>; interrupt-names = "tsens-upper-lower"; #thermal-sensor-cells = <1>; }; slim_msm: slim@c140000{ cell-index = <1>; compatible = "qcom,slim-ngd"; Loading
drivers/thermal/Makefile +1 −1 Original line number Diff line number Diff line Loading @@ -58,4 +58,4 @@ obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o obj-$(CONFIG_THERMAL_QPNP_ADC_TM) += qpnp-adc-tm.o obj-$(CONFIG_THERMAL_TSENS) += msm-tsens.o tsens2xxx.o tsens-dbg.o tsens-mtc.o obj-$(CONFIG_THERMAL_TSENS) += msm-tsens.o tsens2xxx.o tsens-dbg.o tsens-mtc.o tsens1xxx.o
drivers/thermal/msm-tsens.c +31 −2 Original line number Diff line number Diff line /* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -49,6 +49,11 @@ static int tsens_init(struct tsens_device *tmdev) return tmdev->ops->hw_init(tmdev); } static int tsens_calib(struct tsens_device *tmdev) { return tmdev->ops->calibrate(tmdev); } static int tsens_register_interrupts(struct tsens_device *tmdev) { if (tmdev->ops->interrupts_reg) Loading Loading @@ -82,6 +87,9 @@ static const struct of_device_id tsens_table[] = { { .compatible = "qcom,tsens24xx", .data = &data_tsens24xx, }, { .compatible = "qcom,msm8937-tsens", .data = &data_tsens14xx, }, {} }; MODULE_DEVICE_TABLE(of, tsens_table); Loading @@ -97,6 +105,7 @@ static int get_device_tree_data(struct platform_device *pdev, struct device_node *of_node = pdev->dev.of_node; const struct of_device_id *id; const struct tsens_data *data; int rc = 0; struct resource *res_tsens_mem; if (!of_match_node(tsens_table, of_node)) { Loading Loading @@ -150,7 +159,27 @@ static int get_device_tree_data(struct platform_device *pdev, return PTR_ERR(tmdev->tsens_tm_addr); } return 0; /* TSENS eeprom register region */ res_tsens_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tsens_eeprom_physical"); if (!res_tsens_mem) { pr_debug("Could not get tsens physical address resource\n"); } else { tmdev->tsens_calib_addr = devm_ioremap_resource(&pdev->dev, res_tsens_mem); if (IS_ERR(tmdev->tsens_calib_addr)) { dev_err(&pdev->dev, "Failed to IO map TSENS EEPROM registers.\n"); rc = PTR_ERR(tmdev->tsens_calib_addr); } else { rc = tsens_calib(tmdev); if (rc) { pr_err("Error initializing TSENS controller\n"); return rc; } } } return rc; } static int tsens_thermal_zone_register(struct tsens_device *tmdev) Loading
drivers/thermal/tsens.h +16 −3 Original line number Diff line number Diff line /* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -23,10 +23,15 @@ #define DEBUG_SIZE 10 #define TSENS_MAX_SENSORS 16 #define TSENS_1x_MAX_SENSORS 11 #define TSENS_CONTROLLER_ID(n) (n) #define TSENS_CTRL_ADDR(n) (n) #define TSENS_TM_SN_STATUS(n) ((n) + 0xa0) #define ONE_PT_CALIB 0x1 #define ONE_PT_CALIB2 0x2 #define TWO_PT_CALIB 0x3 enum tsens_dbg_type { TSENS_DBG_POLL, TSENS_DBG_LOG_TEMP_READS, Loading Loading @@ -70,6 +75,8 @@ struct tsens_context { int high_temp; int low_temp; int crit_temp; int high_adc_code; int low_adc_code; }; struct tsens_sensor { Loading @@ -79,6 +86,8 @@ struct tsens_sensor { u32 id; const char *sensor_name; struct tsens_context thr_state; int offset; int slope; }; /** Loading @@ -93,6 +102,7 @@ struct tsens_ops { int (*interrupts_reg)(struct tsens_device *); int (*dbg)(struct tsens_device *, u32, u32, int *); int (*sensor_en)(struct tsens_device *, u32); int (*calibrate)(struct tsens_device *); }; struct tsens_irqs { Loading @@ -116,14 +126,15 @@ struct tsens_data { bool wd_bark; u32 wd_bark_mask; bool mtc; bool valid_status_check; }; struct tsens_mtc_sysfs { uint32_t zone_log; u32 zone_log; int zone_mtc; int th1; int th2; uint32_t zone_hist; u32 zone_hist; }; struct tsens_device { Loading @@ -134,6 +145,7 @@ struct tsens_device { struct regmap_field *status_field; void __iomem *tsens_srot_addr; void __iomem *tsens_tm_addr; void __iomem *tsens_calib_addr; const struct tsens_ops *ops; struct tsens_dbg_context tsens_dbg; spinlock_t tsens_crit_lock; Loading @@ -144,6 +156,7 @@ struct tsens_device { }; extern const struct tsens_data data_tsens2xxx, data_tsens23xx, data_tsens24xx; extern const struct tsens_data data_tsens14xx; extern struct list_head tsens_device_list; #endif /* __QCOM_TSENS_H__ */