Loading drivers/thermal/tsens-dbg.c +20 −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 Loading @@ -190,17 +190,34 @@ static struct device_attribute tsens_mtc_dev_attr[] = { __ATTR(zonehist, 0644, zonehist_show, zonehist_store), }; static struct device_attribute tsens_mtc_dev_attr_V14[] = { __ATTR(zonemask, 0644, zonemask_show, zonemask_store), __ATTR(zonelog, 0644, zonelog_show, zonelog_store), }; static int tsens_dbg_mtc_data(struct tsens_device *data, u32 id, u32 dbg_type, int *val) { int result = 0, i; struct tsens_device *tmdev = NULL; struct device_attribute *attr_ptr = NULL; u32 ver_major; u32 ver_minor; u32 num_elem; attr_ptr = tsens_mtc_dev_attr; tmdev = data; ver_major = tmdev->ctrl_data->ver_major; ver_minor = tmdev->ctrl_data->ver_minor; if (ver_major == 1 && ver_minor == 4) { attr_ptr = tsens_mtc_dev_attr_V14; num_elem = ARRAY_SIZE(tsens_mtc_dev_attr_V14); } else { attr_ptr = tsens_mtc_dev_attr; num_elem = ARRAY_SIZE(tsens_mtc_dev_attr); } for (i = 0; i < ARRAY_SIZE(tsens_mtc_dev_attr); i++) { for (i = 0; i < num_elem; i++) { result = device_create_file(&tmdev->pdev->dev, &attr_ptr[i]); if (result < 0) goto error; Loading drivers/thermal/tsens-mtc.c +20 −3 Original line number Diff line number Diff line Loading @@ -76,6 +76,8 @@ int tsens_set_mtc_zone_sw_mask(unsigned int zone, unsigned int th1_enable, unsigned int reg_cntl; void __iomem *sensor_addr; struct tsens_device *tmdev = NULL; u32 ver_major; u32 ver_minor; if (zone > TSENS_NUM_MTC_ZONES_SUPPORT) return -EINVAL; Loading @@ -86,8 +88,16 @@ int tsens_set_mtc_zone_sw_mask(unsigned int zone, unsigned int th1_enable, return -EPROBE_DEFER; } ver_major = tmdev->ctrl_data->ver_major; ver_minor = tmdev->ctrl_data->ver_minor; if (ver_major == 1 && ver_minor == 4) { sensor_addr = TSENS_TM_MTC_ZONE0_SW_MASK_ADDR_V14 (tmdev->tsens_tm_addr); } else { sensor_addr = TSENS_TM_MTC_ZONE0_SW_MASK_ADDR (tmdev->tsens_tm_addr); } if (th1_enable && th2_enable) writel_relaxed(TSENS_MTC_IN_EFFECT, Loading Loading @@ -120,6 +130,8 @@ int tsens_get_mtc_zone_log(unsigned int zone, void *zone_log) int *zlog = (int *)zone_log; void __iomem *sensor_addr; struct tsens_device *tmdev = NULL; u32 ver_major; u32 ver_minor; if (zone > TSENS_NUM_MTC_ZONES_SUPPORT) return -EINVAL; Loading @@ -130,8 +142,13 @@ int tsens_get_mtc_zone_log(unsigned int zone, void *zone_log) return -EPROBE_DEFER; } sensor_addr = TSENS_TM_MTC_ZONE0_LOG(tmdev->tsens_tm_addr); ver_major = tmdev->ctrl_data->ver_major; ver_minor = tmdev->ctrl_data->ver_minor; if (ver_major == 1 && ver_minor == 4) sensor_addr = TSENS_TM_MTC_ZONE0_LOG_V14(tmdev->tsens_tm_addr); else sensor_addr = TSENS_TM_MTC_ZONE0_LOG(tmdev->tsens_tm_addr); reg_cntl = readl_relaxed((sensor_addr + (zone * TSENS_SN_ADDR_OFFSET))); is_valid = (reg_cntl & TSENS_LOGS_VALID_MASK) Loading drivers/thermal/tsens-mtc.h +3 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,9 @@ #define TSENS_TM_MTC_ZONE0_SW_MASK_ADDR(n) ((n) + 0x140) #define TSENS_TM_MTC_ZONE0_LOG(n) ((n) + 0x150) #define TSENS_TM_MTC_ZONE0_HISTORY(n) ((n) + 0x160) #define TSENS_TM_MTC_ZONE0_SW_MASK_ADDR_V14(n) ((n) + 0xC0) #define TSENS_TM_MTC_ZONE0_LOG_V14(n) ((n) + 0xD0) #define TSENS_SN_ADDR_OFFSET 0x4 #define TSENS_RESET_HISTORY_MASK 0x4 #define TSENS_ZONEMASK_PARAMS 3 Loading drivers/thermal/tsens.h +2 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,8 @@ struct tsens_data { u32 wd_bark_mask; bool mtc; bool valid_status_check; u32 ver_major; u32 ver_minor; }; struct tsens_mtc_sysfs { Loading drivers/thermal/tsens1xxx.c +19 −4 Original line number Diff line number Diff line Loading @@ -306,6 +306,10 @@ static int tsens1xxx_get_temp(struct tsens_sensor *sensor, int *temp) *temp = code_to_degc(last_temp, sensor); *temp = *temp * TSENS_SCALE_MILLIDEG; if (tmdev->ops->dbg) tmdev->ops->dbg(tmdev, (u32)sensor->hw_id, TSENS_DBG_LOG_TEMP_READS, temp); return 0; } Loading Loading @@ -565,6 +569,9 @@ static irqreturn_t tsens_irq_thread(int irq, void *data) /* Disable monitoring sensor trip threshold for triggered sensor */ mb(); if (tm->ops->dbg) tm->ops->dbg(tm, 0, TSENS_DBG_LOG_INTERRUPT_TIMESTAMP, NULL); return IRQ_HANDLED; } Loading Loading @@ -600,6 +607,11 @@ static int tsens1xxx_hw_init(struct tsens_device *tmdev) spin_lock_init(&tmdev->tsens_upp_low_lock); if (tmdev->ctrl_data->mtc) { if (tmdev->ops->dbg) tmdev->ops->dbg(tmdev, 0, TSENS_DBG_MTC_DATA, NULL); } return 0; } Loading Loading @@ -649,10 +661,13 @@ static const struct tsens_ops ops_tsens1xxx = { .interrupts_reg = tsens1xxx_register_interrupts, .sensor_en = tsens1xxx_hw_sensor_en, .calibrate = calibrate_8937, .dbg = tsens2xxx_dbg, }; const struct tsens_data data_tsens14xx = { .ops = &ops_tsens1xxx, .valid_status_check = true, .mtc = true, .ver_major = 1, .ver_minor = 4, }; Loading
drivers/thermal/tsens-dbg.c +20 −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 Loading @@ -190,17 +190,34 @@ static struct device_attribute tsens_mtc_dev_attr[] = { __ATTR(zonehist, 0644, zonehist_show, zonehist_store), }; static struct device_attribute tsens_mtc_dev_attr_V14[] = { __ATTR(zonemask, 0644, zonemask_show, zonemask_store), __ATTR(zonelog, 0644, zonelog_show, zonelog_store), }; static int tsens_dbg_mtc_data(struct tsens_device *data, u32 id, u32 dbg_type, int *val) { int result = 0, i; struct tsens_device *tmdev = NULL; struct device_attribute *attr_ptr = NULL; u32 ver_major; u32 ver_minor; u32 num_elem; attr_ptr = tsens_mtc_dev_attr; tmdev = data; ver_major = tmdev->ctrl_data->ver_major; ver_minor = tmdev->ctrl_data->ver_minor; if (ver_major == 1 && ver_minor == 4) { attr_ptr = tsens_mtc_dev_attr_V14; num_elem = ARRAY_SIZE(tsens_mtc_dev_attr_V14); } else { attr_ptr = tsens_mtc_dev_attr; num_elem = ARRAY_SIZE(tsens_mtc_dev_attr); } for (i = 0; i < ARRAY_SIZE(tsens_mtc_dev_attr); i++) { for (i = 0; i < num_elem; i++) { result = device_create_file(&tmdev->pdev->dev, &attr_ptr[i]); if (result < 0) goto error; Loading
drivers/thermal/tsens-mtc.c +20 −3 Original line number Diff line number Diff line Loading @@ -76,6 +76,8 @@ int tsens_set_mtc_zone_sw_mask(unsigned int zone, unsigned int th1_enable, unsigned int reg_cntl; void __iomem *sensor_addr; struct tsens_device *tmdev = NULL; u32 ver_major; u32 ver_minor; if (zone > TSENS_NUM_MTC_ZONES_SUPPORT) return -EINVAL; Loading @@ -86,8 +88,16 @@ int tsens_set_mtc_zone_sw_mask(unsigned int zone, unsigned int th1_enable, return -EPROBE_DEFER; } ver_major = tmdev->ctrl_data->ver_major; ver_minor = tmdev->ctrl_data->ver_minor; if (ver_major == 1 && ver_minor == 4) { sensor_addr = TSENS_TM_MTC_ZONE0_SW_MASK_ADDR_V14 (tmdev->tsens_tm_addr); } else { sensor_addr = TSENS_TM_MTC_ZONE0_SW_MASK_ADDR (tmdev->tsens_tm_addr); } if (th1_enable && th2_enable) writel_relaxed(TSENS_MTC_IN_EFFECT, Loading Loading @@ -120,6 +130,8 @@ int tsens_get_mtc_zone_log(unsigned int zone, void *zone_log) int *zlog = (int *)zone_log; void __iomem *sensor_addr; struct tsens_device *tmdev = NULL; u32 ver_major; u32 ver_minor; if (zone > TSENS_NUM_MTC_ZONES_SUPPORT) return -EINVAL; Loading @@ -130,8 +142,13 @@ int tsens_get_mtc_zone_log(unsigned int zone, void *zone_log) return -EPROBE_DEFER; } sensor_addr = TSENS_TM_MTC_ZONE0_LOG(tmdev->tsens_tm_addr); ver_major = tmdev->ctrl_data->ver_major; ver_minor = tmdev->ctrl_data->ver_minor; if (ver_major == 1 && ver_minor == 4) sensor_addr = TSENS_TM_MTC_ZONE0_LOG_V14(tmdev->tsens_tm_addr); else sensor_addr = TSENS_TM_MTC_ZONE0_LOG(tmdev->tsens_tm_addr); reg_cntl = readl_relaxed((sensor_addr + (zone * TSENS_SN_ADDR_OFFSET))); is_valid = (reg_cntl & TSENS_LOGS_VALID_MASK) Loading
drivers/thermal/tsens-mtc.h +3 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,9 @@ #define TSENS_TM_MTC_ZONE0_SW_MASK_ADDR(n) ((n) + 0x140) #define TSENS_TM_MTC_ZONE0_LOG(n) ((n) + 0x150) #define TSENS_TM_MTC_ZONE0_HISTORY(n) ((n) + 0x160) #define TSENS_TM_MTC_ZONE0_SW_MASK_ADDR_V14(n) ((n) + 0xC0) #define TSENS_TM_MTC_ZONE0_LOG_V14(n) ((n) + 0xD0) #define TSENS_SN_ADDR_OFFSET 0x4 #define TSENS_RESET_HISTORY_MASK 0x4 #define TSENS_ZONEMASK_PARAMS 3 Loading
drivers/thermal/tsens.h +2 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,8 @@ struct tsens_data { u32 wd_bark_mask; bool mtc; bool valid_status_check; u32 ver_major; u32 ver_minor; }; struct tsens_mtc_sysfs { Loading
drivers/thermal/tsens1xxx.c +19 −4 Original line number Diff line number Diff line Loading @@ -306,6 +306,10 @@ static int tsens1xxx_get_temp(struct tsens_sensor *sensor, int *temp) *temp = code_to_degc(last_temp, sensor); *temp = *temp * TSENS_SCALE_MILLIDEG; if (tmdev->ops->dbg) tmdev->ops->dbg(tmdev, (u32)sensor->hw_id, TSENS_DBG_LOG_TEMP_READS, temp); return 0; } Loading Loading @@ -565,6 +569,9 @@ static irqreturn_t tsens_irq_thread(int irq, void *data) /* Disable monitoring sensor trip threshold for triggered sensor */ mb(); if (tm->ops->dbg) tm->ops->dbg(tm, 0, TSENS_DBG_LOG_INTERRUPT_TIMESTAMP, NULL); return IRQ_HANDLED; } Loading Loading @@ -600,6 +607,11 @@ static int tsens1xxx_hw_init(struct tsens_device *tmdev) spin_lock_init(&tmdev->tsens_upp_low_lock); if (tmdev->ctrl_data->mtc) { if (tmdev->ops->dbg) tmdev->ops->dbg(tmdev, 0, TSENS_DBG_MTC_DATA, NULL); } return 0; } Loading Loading @@ -649,10 +661,13 @@ static const struct tsens_ops ops_tsens1xxx = { .interrupts_reg = tsens1xxx_register_interrupts, .sensor_en = tsens1xxx_hw_sensor_en, .calibrate = calibrate_8937, .dbg = tsens2xxx_dbg, }; const struct tsens_data data_tsens14xx = { .ops = &ops_tsens1xxx, .valid_status_check = true, .mtc = true, .ver_major = 1, .ver_minor = 4, };