Lines Matching refs:mt

231 	struct mtk_thermal *mt;  member
528 static int raw_to_mcelsius(struct mtk_thermal *mt, int sensno, s32 raw) in raw_to_mcelsius() argument
535 tmp /= mt->conf->cali_val + mt->o_slope; in raw_to_mcelsius()
536 tmp /= 10000 + mt->adc_ge; in raw_to_mcelsius()
537 tmp *= raw - mt->vts[sensno] - 3350; in raw_to_mcelsius()
540 return mt->degc_cali * 500 - tmp; in raw_to_mcelsius()
552 struct mtk_thermal *mt = bank->mt; in mtk_thermal_get_bank() local
555 if (mt->conf->need_switch_bank) { in mtk_thermal_get_bank()
556 mutex_lock(&mt->lock); in mtk_thermal_get_bank()
558 val = readl(mt->thermal_base + PTPCORESEL); in mtk_thermal_get_bank()
561 writel(val, mt->thermal_base + PTPCORESEL); in mtk_thermal_get_bank()
573 struct mtk_thermal *mt = bank->mt; in mtk_thermal_put_bank() local
575 if (mt->conf->need_switch_bank) in mtk_thermal_put_bank()
576 mutex_unlock(&mt->lock); in mtk_thermal_put_bank()
588 struct mtk_thermal *mt = bank->mt; in mtk_thermal_bank_temperature() local
589 const struct mtk_thermal_data *conf = mt->conf; in mtk_thermal_bank_temperature()
594 raw = readl(mt->thermal_base + in mtk_thermal_bank_temperature()
597 temp = raw_to_mcelsius(mt, in mtk_thermal_bank_temperature()
618 struct mtk_thermal *mt = data; in mtk_read_temp() local
622 for (i = 0; i < mt->conf->num_banks; i++) { in mtk_read_temp()
623 struct mtk_thermal_bank *bank = &mt->banks[i]; in mtk_read_temp()
641 static void mtk_thermal_init_bank(struct mtk_thermal *mt, int num, in mtk_thermal_init_bank() argument
645 struct mtk_thermal_bank *bank = &mt->banks[num]; in mtk_thermal_init_bank()
646 const struct mtk_thermal_data *conf = mt->conf; in mtk_thermal_init_bank()
649 int offset = mt->conf->controller_offset[ctrl_id]; in mtk_thermal_init_bank()
650 void __iomem *controller_base = mt->thermal_base + offset; in mtk_thermal_init_bank()
653 bank->mt = mt; in mtk_thermal_init_bank()
736 mt->thermal_base + in mtk_thermal_init_bank()
762 struct mtk_thermal *mt) in mtk_thermal_get_calibration_data() argument
770 mt->adc_ge = 512; in mtk_thermal_get_calibration_data()
771 for (i = 0; i < mt->conf->num_sensors; i++) in mtk_thermal_get_calibration_data()
772 mt->vts[i] = 260; in mtk_thermal_get_calibration_data()
773 mt->degc_cali = 40; in mtk_thermal_get_calibration_data()
774 mt->o_slope = 0; in mtk_thermal_get_calibration_data()
797 mt->adc_ge = CALIB_BUF1_ADC_GE(buf[1]); in mtk_thermal_get_calibration_data()
799 for (i = 0; i < mt->conf->num_sensors; i++) { in mtk_thermal_get_calibration_data()
800 switch (mt->conf->vts_index[i]) { in mtk_thermal_get_calibration_data()
802 mt->vts[VTS1] = CALIB_BUF0_VTS_TS1(buf[0]); in mtk_thermal_get_calibration_data()
805 mt->vts[VTS2] = CALIB_BUF0_VTS_TS2(buf[0]); in mtk_thermal_get_calibration_data()
808 mt->vts[VTS3] = CALIB_BUF1_VTS_TS3(buf[1]); in mtk_thermal_get_calibration_data()
811 mt->vts[VTS4] = CALIB_BUF2_VTS_TS4(buf[2]); in mtk_thermal_get_calibration_data()
814 mt->vts[VTS5] = CALIB_BUF2_VTS_TS5(buf[2]); in mtk_thermal_get_calibration_data()
817 mt->vts[VTSABB] = CALIB_BUF2_VTS_TSABB(buf[2]); in mtk_thermal_get_calibration_data()
824 mt->degc_cali = CALIB_BUF0_DEGC_CALI(buf[0]); in mtk_thermal_get_calibration_data()
827 mt->o_slope = -CALIB_BUF0_O_SLOPE(buf[0]); in mtk_thermal_get_calibration_data()
829 mt->o_slope = CALIB_BUF0_O_SLOPE(buf[0]); in mtk_thermal_get_calibration_data()
869 struct mtk_thermal *mt; in mtk_thermal_probe() local
874 mt = devm_kzalloc(&pdev->dev, sizeof(*mt), GFP_KERNEL); in mtk_thermal_probe()
875 if (!mt) in mtk_thermal_probe()
878 mt->conf = of_device_get_match_data(&pdev->dev); in mtk_thermal_probe()
880 mt->clk_peri_therm = devm_clk_get(&pdev->dev, "therm"); in mtk_thermal_probe()
881 if (IS_ERR(mt->clk_peri_therm)) in mtk_thermal_probe()
882 return PTR_ERR(mt->clk_peri_therm); in mtk_thermal_probe()
884 mt->clk_auxadc = devm_clk_get(&pdev->dev, "auxadc"); in mtk_thermal_probe()
885 if (IS_ERR(mt->clk_auxadc)) in mtk_thermal_probe()
886 return PTR_ERR(mt->clk_auxadc); in mtk_thermal_probe()
889 mt->thermal_base = devm_ioremap_resource(&pdev->dev, res); in mtk_thermal_probe()
890 if (IS_ERR(mt->thermal_base)) in mtk_thermal_probe()
891 return PTR_ERR(mt->thermal_base); in mtk_thermal_probe()
893 ret = mtk_thermal_get_calibration_data(&pdev->dev, mt); in mtk_thermal_probe()
897 mutex_init(&mt->lock); in mtk_thermal_probe()
899 mt->dev = &pdev->dev; in mtk_thermal_probe()
935 ret = clk_prepare_enable(mt->clk_auxadc); in mtk_thermal_probe()
941 ret = clk_prepare_enable(mt->clk_peri_therm); in mtk_thermal_probe()
947 for (ctrl_id = 0; ctrl_id < mt->conf->num_controller ; ctrl_id++) in mtk_thermal_probe()
948 for (i = 0; i < mt->conf->num_banks; i++) in mtk_thermal_probe()
949 mtk_thermal_init_bank(mt, i, apmixed_phys_base, in mtk_thermal_probe()
952 platform_set_drvdata(pdev, mt); in mtk_thermal_probe()
954 tzdev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, mt, in mtk_thermal_probe()
964 clk_disable_unprepare(mt->clk_peri_therm); in mtk_thermal_probe()
966 clk_disable_unprepare(mt->clk_auxadc); in mtk_thermal_probe()
973 struct mtk_thermal *mt = platform_get_drvdata(pdev); in mtk_thermal_remove() local
975 clk_disable_unprepare(mt->clk_peri_therm); in mtk_thermal_remove()
976 clk_disable_unprepare(mt->clk_auxadc); in mtk_thermal_remove()