Loading drivers/thermal/tsens2xxx.c +70 −52 Original line number Diff line number Diff line Loading @@ -83,12 +83,70 @@ static void msm_tsens_convert_temp(int last_temp, int *temp) *temp = last_temp * TSENS_TM_SCALE_DECI_MILLIDEG; } static int __tsens2xxx_hw_init(struct tsens_device *tmdev) { void __iomem *srot_addr; void __iomem *sensor_int_mask_addr; unsigned int srot_val, crit_mask, crit_val; void __iomem *int_mask_addr; srot_addr = TSENS_CTRL_ADDR(tmdev->tsens_srot_addr + 0x4); srot_val = readl_relaxed(srot_addr); if (!(srot_val & TSENS_EN)) { pr_err("TSENS device is not enabled\n"); return -ENODEV; } if (tmdev->ctrl_data->cycle_monitor) { sensor_int_mask_addr = TSENS_TM_CRITICAL_INT_MASK(tmdev->tsens_tm_addr); crit_mask = readl_relaxed(sensor_int_mask_addr); crit_val = TSENS_TM_CRITICAL_CYCLE_MONITOR; if (tmdev->ctrl_data->cycle_compltn_monitor_mask) writel_relaxed((crit_mask | crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); else writel_relaxed((crit_mask & ~crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); /*Update critical cycle monitoring*/ mb(); } if (tmdev->ctrl_data->wd_bark) { sensor_int_mask_addr = TSENS_TM_CRITICAL_INT_MASK(tmdev->tsens_tm_addr); crit_mask = readl_relaxed(sensor_int_mask_addr); crit_val = TSENS_TM_CRITICAL_WD_BARK; if (tmdev->ctrl_data->wd_bark_mask) writel_relaxed((crit_mask | crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); else writel_relaxed((crit_mask & ~crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); /*Update watchdog monitoring*/ mb(); } int_mask_addr = TSENS_TM_UPPER_LOWER_INT_MASK(tmdev->tsens_tm_addr); writel_relaxed(TSENS_TM_UPPER_LOWER_INT_DISABLE, int_mask_addr); writel_relaxed(TSENS_TM_CRITICAL_INT_EN | TSENS_TM_UPPER_INT_EN | TSENS_TM_LOWER_INT_EN, TSENS_TM_INT_EN(tmdev->tsens_tm_addr)); return 0; } static int tsens2xxx_get_temp(struct tsens_sensor *sensor, int *temp) { struct tsens_device *tmdev = NULL, *tmdev_itr; unsigned int code, ret, tsens_ret; void __iomem *sensor_addr, *trdy; int last_temp = 0, last_temp2 = 0, last_temp3 = 0, count = 0; int rc = 0, last_temp = 0, last_temp2 = 0, last_temp3 = 0, count = 0; static atomic_t in_tsens_reinit; if (!sensor) Loading Loading @@ -172,6 +230,13 @@ static int tsens2xxx_get_temp(struct tsens_sensor *sensor, int *temp) /* Notify thermal fwk */ list_for_each_entry(tmdev_itr, &tsens_device_list, list) { rc = __tsens2xxx_hw_init(tmdev_itr); if (rc) { pr_err( "%s: Failed to re-initialize TSENS controller\n", __func__); BUG(); } queue_work(tmdev_itr->tsens_reinit_work, &tmdev_itr->therm_fwk_notify); } Loading Loading @@ -713,58 +778,11 @@ static int tsens2xxx_hw_sensor_en(struct tsens_device *tmdev, static int tsens2xxx_hw_init(struct tsens_device *tmdev) { void __iomem *srot_addr; void __iomem *sensor_int_mask_addr; unsigned int srot_val, crit_mask, crit_val; void __iomem *int_mask_addr; srot_addr = TSENS_CTRL_ADDR(tmdev->tsens_srot_addr + 0x4); srot_val = readl_relaxed(srot_addr); if (!(srot_val & TSENS_EN)) { pr_err("TSENS device is not enabled\n"); return -ENODEV; } if (tmdev->ctrl_data->cycle_monitor) { sensor_int_mask_addr = TSENS_TM_CRITICAL_INT_MASK(tmdev->tsens_tm_addr); crit_mask = readl_relaxed(sensor_int_mask_addr); crit_val = TSENS_TM_CRITICAL_CYCLE_MONITOR; if (tmdev->ctrl_data->cycle_compltn_monitor_mask) writel_relaxed((crit_mask | crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); else writel_relaxed((crit_mask & ~crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); /*Update critical cycle monitoring*/ mb(); } if (tmdev->ctrl_data->wd_bark) { sensor_int_mask_addr = TSENS_TM_CRITICAL_INT_MASK(tmdev->tsens_tm_addr); crit_mask = readl_relaxed(sensor_int_mask_addr); crit_val = TSENS_TM_CRITICAL_WD_BARK; if (tmdev->ctrl_data->wd_bark_mask) writel_relaxed((crit_mask | crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); else writel_relaxed((crit_mask & ~crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); /*Update watchdog monitoring*/ mb(); } int_mask_addr = TSENS_TM_UPPER_LOWER_INT_MASK(tmdev->tsens_tm_addr); writel_relaxed(TSENS_TM_UPPER_LOWER_INT_DISABLE, int_mask_addr); int rc = 0; writel_relaxed(TSENS_TM_CRITICAL_INT_EN | TSENS_TM_UPPER_INT_EN | TSENS_TM_LOWER_INT_EN, TSENS_TM_INT_EN(tmdev->tsens_tm_addr)); rc = __tsens2xxx_hw_init(tmdev); if (rc) return rc; spin_lock_init(&tmdev->tsens_crit_lock); spin_lock_init(&tmdev->tsens_upp_low_lock); Loading Loading
drivers/thermal/tsens2xxx.c +70 −52 Original line number Diff line number Diff line Loading @@ -83,12 +83,70 @@ static void msm_tsens_convert_temp(int last_temp, int *temp) *temp = last_temp * TSENS_TM_SCALE_DECI_MILLIDEG; } static int __tsens2xxx_hw_init(struct tsens_device *tmdev) { void __iomem *srot_addr; void __iomem *sensor_int_mask_addr; unsigned int srot_val, crit_mask, crit_val; void __iomem *int_mask_addr; srot_addr = TSENS_CTRL_ADDR(tmdev->tsens_srot_addr + 0x4); srot_val = readl_relaxed(srot_addr); if (!(srot_val & TSENS_EN)) { pr_err("TSENS device is not enabled\n"); return -ENODEV; } if (tmdev->ctrl_data->cycle_monitor) { sensor_int_mask_addr = TSENS_TM_CRITICAL_INT_MASK(tmdev->tsens_tm_addr); crit_mask = readl_relaxed(sensor_int_mask_addr); crit_val = TSENS_TM_CRITICAL_CYCLE_MONITOR; if (tmdev->ctrl_data->cycle_compltn_monitor_mask) writel_relaxed((crit_mask | crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); else writel_relaxed((crit_mask & ~crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); /*Update critical cycle monitoring*/ mb(); } if (tmdev->ctrl_data->wd_bark) { sensor_int_mask_addr = TSENS_TM_CRITICAL_INT_MASK(tmdev->tsens_tm_addr); crit_mask = readl_relaxed(sensor_int_mask_addr); crit_val = TSENS_TM_CRITICAL_WD_BARK; if (tmdev->ctrl_data->wd_bark_mask) writel_relaxed((crit_mask | crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); else writel_relaxed((crit_mask & ~crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); /*Update watchdog monitoring*/ mb(); } int_mask_addr = TSENS_TM_UPPER_LOWER_INT_MASK(tmdev->tsens_tm_addr); writel_relaxed(TSENS_TM_UPPER_LOWER_INT_DISABLE, int_mask_addr); writel_relaxed(TSENS_TM_CRITICAL_INT_EN | TSENS_TM_UPPER_INT_EN | TSENS_TM_LOWER_INT_EN, TSENS_TM_INT_EN(tmdev->tsens_tm_addr)); return 0; } static int tsens2xxx_get_temp(struct tsens_sensor *sensor, int *temp) { struct tsens_device *tmdev = NULL, *tmdev_itr; unsigned int code, ret, tsens_ret; void __iomem *sensor_addr, *trdy; int last_temp = 0, last_temp2 = 0, last_temp3 = 0, count = 0; int rc = 0, last_temp = 0, last_temp2 = 0, last_temp3 = 0, count = 0; static atomic_t in_tsens_reinit; if (!sensor) Loading Loading @@ -172,6 +230,13 @@ static int tsens2xxx_get_temp(struct tsens_sensor *sensor, int *temp) /* Notify thermal fwk */ list_for_each_entry(tmdev_itr, &tsens_device_list, list) { rc = __tsens2xxx_hw_init(tmdev_itr); if (rc) { pr_err( "%s: Failed to re-initialize TSENS controller\n", __func__); BUG(); } queue_work(tmdev_itr->tsens_reinit_work, &tmdev_itr->therm_fwk_notify); } Loading Loading @@ -713,58 +778,11 @@ static int tsens2xxx_hw_sensor_en(struct tsens_device *tmdev, static int tsens2xxx_hw_init(struct tsens_device *tmdev) { void __iomem *srot_addr; void __iomem *sensor_int_mask_addr; unsigned int srot_val, crit_mask, crit_val; void __iomem *int_mask_addr; srot_addr = TSENS_CTRL_ADDR(tmdev->tsens_srot_addr + 0x4); srot_val = readl_relaxed(srot_addr); if (!(srot_val & TSENS_EN)) { pr_err("TSENS device is not enabled\n"); return -ENODEV; } if (tmdev->ctrl_data->cycle_monitor) { sensor_int_mask_addr = TSENS_TM_CRITICAL_INT_MASK(tmdev->tsens_tm_addr); crit_mask = readl_relaxed(sensor_int_mask_addr); crit_val = TSENS_TM_CRITICAL_CYCLE_MONITOR; if (tmdev->ctrl_data->cycle_compltn_monitor_mask) writel_relaxed((crit_mask | crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); else writel_relaxed((crit_mask & ~crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); /*Update critical cycle monitoring*/ mb(); } if (tmdev->ctrl_data->wd_bark) { sensor_int_mask_addr = TSENS_TM_CRITICAL_INT_MASK(tmdev->tsens_tm_addr); crit_mask = readl_relaxed(sensor_int_mask_addr); crit_val = TSENS_TM_CRITICAL_WD_BARK; if (tmdev->ctrl_data->wd_bark_mask) writel_relaxed((crit_mask | crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); else writel_relaxed((crit_mask & ~crit_val), (TSENS_TM_CRITICAL_INT_MASK (tmdev->tsens_tm_addr))); /*Update watchdog monitoring*/ mb(); } int_mask_addr = TSENS_TM_UPPER_LOWER_INT_MASK(tmdev->tsens_tm_addr); writel_relaxed(TSENS_TM_UPPER_LOWER_INT_DISABLE, int_mask_addr); int rc = 0; writel_relaxed(TSENS_TM_CRITICAL_INT_EN | TSENS_TM_UPPER_INT_EN | TSENS_TM_LOWER_INT_EN, TSENS_TM_INT_EN(tmdev->tsens_tm_addr)); rc = __tsens2xxx_hw_init(tmdev); if (rc) return rc; spin_lock_init(&tmdev->tsens_crit_lock); spin_lock_init(&tmdev->tsens_upp_low_lock); Loading