Lines Matching refs:ts

303 	struct tegra_soctherm *ts;  member
368 static inline void ccroc_writel(struct tegra_soctherm *ts, u32 value, u32 reg) in ccroc_writel() argument
370 writel(value, (ts->ccroc_regs + reg)); in ccroc_writel()
380 static inline u32 ccroc_readl(struct tegra_soctherm *ts, u32 reg) in ccroc_readl() argument
382 return readl(ts->ccroc_regs + reg); in ccroc_readl()
478 struct tegra_soctherm *ts = dev_get_drvdata(dev); in thermtrip_program() local
485 temp = enforce_temp_range(dev, trip_temp) / ts->soc->thresh_grain; in thermtrip_program()
487 r = readl(ts->regs + THERMCTL_THERMTRIP_CTL); in thermtrip_program()
491 writel(r, ts->regs + THERMCTL_THERMTRIP_CTL); in thermtrip_program()
518 struct tegra_soctherm *ts = dev_get_drvdata(dev); in throttrip_program() local
526 temp = enforce_temp_range(dev, trip_temp) / ts->soc->thresh_grain; in throttrip_program()
544 r = readl(ts->regs + reg_off); in throttrip_program()
550 writel(r, ts->regs + reg_off); in throttrip_program()
556 find_throttle_cfg_by_name(struct tegra_soctherm *ts, const char *name) in find_throttle_cfg_by_name() argument
560 for (i = 0; ts->throt_cfgs[i].name; i++) in find_throttle_cfg_by_name()
561 if (!strcmp(ts->throt_cfgs[i].name, name)) in find_throttle_cfg_by_name()
562 return &ts->throt_cfgs[i]; in find_throttle_cfg_by_name()
567 static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id) in tsensor_group_thermtrip_get() argument
570 struct tsensor_group_thermtrips *tt = ts->soc->thermtrips; in tsensor_group_thermtrip_get()
576 for (i = 0; i < ts->soc->num_ttgs; i++) { in tsensor_group_thermtrip_get()
588 struct tegra_soctherm *ts = zone->ts; in tegra_thermctl_set_trip_temp() local
607 if (min_low_temp == tsensor_group_thermtrip_get(ts, sg->id)) in tegra_thermctl_set_trip_temp()
619 if (!ts->throt_cfgs[i].init) in tegra_thermctl_set_trip_temp()
622 cdev = ts->throt_cfgs[i].cdev; in tegra_thermctl_set_trip_temp()
624 stc = find_throttle_cfg_by_name(ts, cdev->type); in tegra_thermctl_set_trip_temp()
640 mutex_lock(&zn->ts->thermctl_lock); in thermal_irq_enable()
641 r = readl(zn->ts->regs + THERMCTL_INTR_ENABLE); in thermal_irq_enable()
643 writel(r, zn->ts->regs + THERMCTL_INTR_ENABLE); in thermal_irq_enable()
644 mutex_unlock(&zn->ts->thermctl_lock); in thermal_irq_enable()
652 mutex_lock(&zn->ts->thermctl_lock); in thermal_irq_disable()
653 r = readl(zn->ts->regs + THERMCTL_INTR_DISABLE); in thermal_irq_disable()
655 writel(r, zn->ts->regs + THERMCTL_INTR_DISABLE); in thermal_irq_disable()
656 mutex_unlock(&zn->ts->thermctl_lock); in thermal_irq_disable()
666 r = readl(zone->ts->regs + zone->sg->thermctl_lvl0_offset); in tegra_thermctl_set_trips()
668 writel(r, zone->ts->regs + zone->sg->thermctl_lvl0_offset); in tegra_thermctl_set_trips()
670 lo = enforce_temp_range(zone->dev, lo) / zone->ts->soc->thresh_grain; in tegra_thermctl_set_trips()
671 hi = enforce_temp_range(zone->dev, hi) / zone->ts->soc->thresh_grain; in tegra_thermctl_set_trips()
677 writel(r, zone->ts->regs + zone->sg->thermctl_lvl0_offset); in tegra_thermctl_set_trips()
738 struct tegra_soctherm *ts = dev_get_drvdata(dev); in tegra_soctherm_set_hwtrips() local
743 temperature = tsensor_group_thermtrip_get(ts, sg->id); in tegra_soctherm_set_hwtrips()
767 if (!ts->throt_cfgs[i].init) in tegra_soctherm_set_hwtrips()
770 cdev = ts->throt_cfgs[i].cdev; in tegra_soctherm_set_hwtrips()
772 stc = find_throttle_cfg_by_name(ts, cdev->type); in tegra_soctherm_set_hwtrips()
798 struct tegra_soctherm *ts = dev_id; in soctherm_thermal_isr() local
810 r = readl(ts->regs + THERMCTL_INTR_STATUS); in soctherm_thermal_isr()
811 writel(r, ts->regs + THERMCTL_INTR_DISABLE); in soctherm_thermal_isr()
835 struct tegra_soctherm *ts = dev_id; in soctherm_thermal_isr_thread() local
839 st = readl(ts->regs + THERMCTL_INTR_STATUS); in soctherm_thermal_isr_thread()
856 writel(ex, ts->regs + THERMCTL_INTR_STATUS); in soctherm_thermal_isr_thread()
860 tz = ts->thermctl_tzs[TEGRA124_SOCTHERM_SENSOR_CPU]; in soctherm_thermal_isr_thread()
866 tz = ts->thermctl_tzs[TEGRA124_SOCTHERM_SENSOR_GPU]; in soctherm_thermal_isr_thread()
872 tz = ts->thermctl_tzs[TEGRA124_SOCTHERM_SENSOR_PLLX]; in soctherm_thermal_isr_thread()
878 tz = ts->thermctl_tzs[TEGRA124_SOCTHERM_SENSOR_MEM]; in soctherm_thermal_isr_thread()
891 writel(st, ts->regs + THERMCTL_INTR_STATUS); in soctherm_thermal_isr_thread()
907 static void soctherm_oc_intr_enable(struct tegra_soctherm *ts, in soctherm_oc_intr_enable() argument
916 r = readl(ts->regs + OC_INTR_ENABLE); in soctherm_oc_intr_enable()
934 writel(r, ts->regs + OC_INTR_ENABLE); in soctherm_oc_intr_enable()
997 struct tegra_soctherm *ts = arg; in soctherm_edp_isr_thread() local
1000 st = readl(ts->regs + OC_INTR_STATUS); in soctherm_edp_isr_thread()
1011 writel(st, ts->regs + OC_INTR_STATUS); in soctherm_edp_isr_thread()
1015 soctherm_oc_intr_enable(ts, THROTTLE_OC1, true); in soctherm_edp_isr_thread()
1018 soctherm_oc_intr_enable(ts, THROTTLE_OC2, true); in soctherm_edp_isr_thread()
1021 soctherm_oc_intr_enable(ts, THROTTLE_OC3, true); in soctherm_edp_isr_thread()
1024 soctherm_oc_intr_enable(ts, THROTTLE_OC4, true); in soctherm_edp_isr_thread()
1045 writel(st, ts->regs + OC_INTR_STATUS); in soctherm_edp_isr_thread()
1068 struct tegra_soctherm *ts = arg; in soctherm_edp_isr() local
1071 if (!ts) in soctherm_edp_isr()
1074 r = readl(ts->regs + OC_INTR_STATUS); in soctherm_edp_isr()
1075 writel(r, ts->regs + OC_INTR_DISABLE); in soctherm_edp_isr()
1257 struct tegra_soctherm *ts = platform_get_drvdata(pdev); in regs_show() local
1258 const struct tegra_tsensor *tsensors = ts->soc->tsensors; in regs_show()
1259 const struct tegra_tsensor_group **ttgs = ts->soc->ttgs; in regs_show()
1265 for (i = 0; i < ts->soc->num_tsensors; i++) { in regs_show()
1266 r = readl(ts->regs + tsensors[i].base + SENSOR_CONFIG1); in regs_show()
1284 r = readl(ts->regs + tsensors[i].base + SENSOR_STATUS1); in regs_show()
1290 r = readl(ts->regs + tsensors[i].base + SENSOR_STATUS0); in regs_show()
1296 r = readl(ts->regs + tsensors[i].base + SENSOR_CONFIG0); in regs_show()
1308 r = readl(ts->regs + tsensors[i].base + SENSOR_CONFIG2); in regs_show()
1315 r = readl(ts->regs + SENSOR_PDIV); in regs_show()
1318 r = readl(ts->regs + SENSOR_HOTSPOT_OFF); in regs_show()
1324 r = readl(ts->regs + SENSOR_TEMP1); in regs_show()
1329 r = readl(ts->regs + SENSOR_TEMP2); in regs_show()
1335 for (i = 0; i < ts->soc->num_ttgs; i++) { in regs_show()
1342 r = readl(ts->regs + THERMCTL_LVL_REG(off, level)); in regs_show()
1346 v = sign_extend32(state, ts->soc->bptt - 1); in regs_show()
1347 v *= ts->soc->thresh_grain; in regs_show()
1352 v = sign_extend32(state, ts->soc->bptt - 1); in regs_show()
1353 v *= ts->soc->thresh_grain; in regs_show()
1393 r = readl(ts->regs + THERMCTL_STATS_CTL); in regs_show()
1402 r = readl(ts->regs + THERMCTL_LVL_REG(off, level)); in regs_show()
1406 r = readl(ts->regs + THERMCTL_LVL_REG(off, level)); in regs_show()
1410 r = readl(ts->regs + THERMCTL_THERMTRIP_CTL); in regs_show()
1413 for (i = 0; i < ts->soc->num_ttgs; i++) { in regs_show()
1417 state *= ts->soc->thresh_grain; in regs_show()
1421 r = readl(ts->regs + THROT_GLOBAL_CFG); in regs_show()
1426 r = readl(ts->regs + THROT_STATUS); in regs_show()
1434 r = readl(ts->regs + CPU_PSKIP_STATUS); in regs_show()
1435 if (ts->soc->use_ccroc) { in regs_show()
1510 struct tegra_soctherm *ts = cdev->devdata; in throt_get_cdev_cur_state() local
1513 r = readl(ts->regs + THROT_STATUS); in throt_get_cdev_cur_state()
1537 struct tegra_soctherm *ts = dev_get_drvdata(dev); in soctherm_thermtrips_parse() local
1538 struct tsensor_group_thermtrips *tt = ts->soc->thermtrips; in soctherm_thermtrips_parse()
1539 const int max_num_prop = ts->soc->num_ttgs * 2; in soctherm_thermtrips_parse()
1608 struct tegra_soctherm *ts = dev_get_drvdata(dev); in soctherm_throt_cfg_parse() local
1619 ret = of_property_read_u32(np, ts->soc->use_ccroc ? in soctherm_throt_cfg_parse()
1623 if (ts->soc->use_ccroc && in soctherm_throt_cfg_parse()
1626 else if (!ts->soc->use_ccroc && val <= 100) in soctherm_throt_cfg_parse()
1656 struct tegra_soctherm *ts = dev_get_drvdata(dev); in soctherm_init_hw_throt_cdev() local
1662 ts->throt_cfgs[i].name = throt_names[i]; in soctherm_init_hw_throt_cdev()
1663 ts->throt_cfgs[i].id = i; in soctherm_init_hw_throt_cdev()
1664 ts->throt_cfgs[i].init = false; in soctherm_init_hw_throt_cdev()
1680 stc = find_throttle_cfg_by_name(ts, name); in soctherm_init_hw_throt_cdev()
1703 (char *)name, ts, in soctherm_init_hw_throt_cdev()
1732 static void throttlectl_cpu_level_cfg(struct tegra_soctherm *ts, int level) in throttlectl_cpu_level_cfg() argument
1756 r = ccroc_readl(ts, CCROC_THROT_PSKIP_RAMP_CPU_REG(level)); in throttlectl_cpu_level_cfg()
1759 ccroc_writel(ts, r, CCROC_THROT_PSKIP_RAMP_CPU_REG(level)); in throttlectl_cpu_level_cfg()
1761 r = ccroc_readl(ts, CCROC_THROT_PSKIP_CTRL_CPU_REG(level)); in throttlectl_cpu_level_cfg()
1765 ccroc_writel(ts, r, CCROC_THROT_PSKIP_CTRL_CPU_REG(level)); in throttlectl_cpu_level_cfg()
1780 static void throttlectl_cpu_level_select(struct tegra_soctherm *ts, in throttlectl_cpu_level_select() argument
1786 switch (ts->throt_cfgs[throt].cpu_throt_level) { in throttlectl_cpu_level_select()
1801 r = readl(ts->regs + THROT_PSKIP_CTRL(throt, THROTTLE_DEV_CPU)); in throttlectl_cpu_level_select()
1805 writel(r, ts->regs + THROT_PSKIP_CTRL(throt, THROTTLE_DEV_CPU)); in throttlectl_cpu_level_select()
1809 writel(r, ts->regs + THROT_PSKIP_RAMP(throt, THROTTLE_DEV_CPU)); in throttlectl_cpu_level_select()
1824 static void throttlectl_cpu_mn(struct tegra_soctherm *ts, in throttlectl_cpu_mn() argument
1831 depth = ts->throt_cfgs[throt].cpu_throt_depth; in throttlectl_cpu_mn()
1834 r = readl(ts->regs + THROT_PSKIP_CTRL(throt, THROTTLE_DEV_CPU)); in throttlectl_cpu_mn()
1838 writel(r, ts->regs + THROT_PSKIP_CTRL(throt, THROTTLE_DEV_CPU)); in throttlectl_cpu_mn()
1840 r = readl(ts->regs + THROT_PSKIP_RAMP(throt, THROTTLE_DEV_CPU)); in throttlectl_cpu_mn()
1843 writel(r, ts->regs + THROT_PSKIP_RAMP(throt, THROTTLE_DEV_CPU)); in throttlectl_cpu_mn()
1856 static void throttlectl_gpu_level_select(struct tegra_soctherm *ts, in throttlectl_gpu_level_select() argument
1861 level = ts->throt_cfgs[throt].gpu_throt_level; in throttlectl_gpu_level_select()
1863 r = readl(ts->regs + THROT_PSKIP_CTRL(throt, THROTTLE_DEV_GPU)); in throttlectl_gpu_level_select()
1866 writel(r, ts->regs + THROT_PSKIP_CTRL(throt, THROTTLE_DEV_GPU)); in throttlectl_gpu_level_select()
1869 static int soctherm_oc_cfg_program(struct tegra_soctherm *ts, in soctherm_oc_cfg_program() argument
1873 struct soctherm_oc_cfg *oc = &ts->throt_cfgs[throt].oc_cfg; in soctherm_oc_cfg_program()
1882 writel(r, ts->regs + ALARM_CFG(throt)); in soctherm_oc_cfg_program()
1883 writel(oc->throt_period, ts->regs + ALARM_THROTTLE_PERIOD(throt)); in soctherm_oc_cfg_program()
1884 writel(oc->alarm_cnt_thresh, ts->regs + ALARM_CNT_THRESHOLD(throt)); in soctherm_oc_cfg_program()
1885 writel(oc->alarm_filter, ts->regs + ALARM_FILTER(throt)); in soctherm_oc_cfg_program()
1886 soctherm_oc_intr_enable(ts, throt, oc->intr_en); in soctherm_oc_cfg_program()
1899 static void soctherm_throttle_program(struct tegra_soctherm *ts, in soctherm_throttle_program() argument
1903 struct soctherm_throt_cfg stc = ts->throt_cfgs[throt]; in soctherm_throttle_program()
1908 if ((throt >= THROTTLE_OC1) && (soctherm_oc_cfg_program(ts, throt))) in soctherm_throttle_program()
1912 if (ts->soc->use_ccroc) in soctherm_throttle_program()
1913 throttlectl_cpu_level_select(ts, throt); in soctherm_throttle_program()
1915 throttlectl_cpu_mn(ts, throt); in soctherm_throttle_program()
1917 throttlectl_gpu_level_select(ts, throt); in soctherm_throttle_program()
1920 writel(r, ts->regs + THROT_PRIORITY_CTRL(throt)); in soctherm_throttle_program()
1923 writel(r, ts->regs + THROT_DELAY_CTRL(throt)); in soctherm_throttle_program()
1925 r = readl(ts->regs + THROT_PRIORITY_LOCK); in soctherm_throttle_program()
1931 writel(r, ts->regs + THROT_PRIORITY_LOCK); in soctherm_throttle_program()
1936 struct tegra_soctherm *ts = dev_get_drvdata(dev); in tegra_soctherm_throttle() local
1941 if (ts->soc->use_ccroc) { in tegra_soctherm_throttle()
1942 throttlectl_cpu_level_cfg(ts, TEGRA_SOCTHERM_THROT_LEVEL_LOW); in tegra_soctherm_throttle()
1943 throttlectl_cpu_level_cfg(ts, TEGRA_SOCTHERM_THROT_LEVEL_MED); in tegra_soctherm_throttle()
1944 throttlectl_cpu_level_cfg(ts, TEGRA_SOCTHERM_THROT_LEVEL_HIGH); in tegra_soctherm_throttle()
1949 soctherm_throttle_program(ts, i); in tegra_soctherm_throttle()
1952 if (ts->soc->use_ccroc) { in tegra_soctherm_throttle()
1953 ccroc_writel(ts, v, CCROC_GLOBAL_CFG); in tegra_soctherm_throttle()
1955 v = ccroc_readl(ts, CCROC_SUPER_CCLKG_DIVIDER); in tegra_soctherm_throttle()
1957 ccroc_writel(ts, v, CCROC_SUPER_CCLKG_DIVIDER); in tegra_soctherm_throttle()
1959 writel(v, ts->regs + THROT_GLOBAL_CFG); in tegra_soctherm_throttle()
1961 v = readl(ts->clk_regs + CAR_SUPER_CCLKG_DIVIDER); in tegra_soctherm_throttle()
1963 writel(v, ts->clk_regs + CAR_SUPER_CCLKG_DIVIDER); in tegra_soctherm_throttle()
1969 writel(v, ts->regs + THERMCTL_STATS_CTL); in tegra_soctherm_throttle()
2189 zone->ts = tegra; in tegra_soctherm_probe()