Lines Matching refs:pvt

187 	struct pvt_device *pvt = file->private_data;  in pvt_ts_coeff_j_read()  local
191 len = scnprintf(buf, sizeof(buf), "%d\n", pvt->ts_coeff.j); in pvt_ts_coeff_j_read()
200 struct pvt_device *pvt = file->private_data; in pvt_ts_coeff_j_write() local
203 ret = kstrtos32_from_user(user_buf, count, 0, &pvt->ts_coeff.j); in pvt_ts_coeff_j_write()
220 struct pvt_device *pvt = (struct pvt_device *)data; in devm_pvt_ts_dbgfs_remove() local
222 debugfs_remove_recursive(pvt->dbgfs_dir); in devm_pvt_ts_dbgfs_remove()
223 pvt->dbgfs_dir = NULL; in devm_pvt_ts_dbgfs_remove()
226 static int pvt_ts_dbgfs_create(struct pvt_device *pvt, struct device *dev) in pvt_ts_dbgfs_create() argument
228 pvt->dbgfs_dir = debugfs_create_dir(dev_name(dev), NULL); in pvt_ts_dbgfs_create()
230 debugfs_create_u32("ts_coeff_h", 0644, pvt->dbgfs_dir, in pvt_ts_dbgfs_create()
231 &pvt->ts_coeff.h); in pvt_ts_dbgfs_create()
232 debugfs_create_u32("ts_coeff_g", 0644, pvt->dbgfs_dir, in pvt_ts_dbgfs_create()
233 &pvt->ts_coeff.g); in pvt_ts_dbgfs_create()
234 debugfs_create_u32("ts_coeff_cal5", 0644, pvt->dbgfs_dir, in pvt_ts_dbgfs_create()
235 &pvt->ts_coeff.cal5); in pvt_ts_dbgfs_create()
236 debugfs_create_file("ts_coeff_j", 0644, pvt->dbgfs_dir, pvt, in pvt_ts_dbgfs_create()
239 return devm_add_action_or_reset(dev, devm_pvt_ts_dbgfs_remove, pvt); in pvt_ts_dbgfs_create()
260 static long pvt_calc_temp(struct pvt_device *pvt, u32 nbs) in pvt_calc_temp() argument
266 struct temp_coeff *ts_coeff = &pvt->ts_coeff; in pvt_calc_temp()
271 div_s64(ts_coeff->j * (s64)pvt->ip_freq, HZ_PER_MHZ); in pvt_calc_temp()
278 struct pvt_device *pvt = dev_get_drvdata(dev); in pvt_read_temp() local
279 struct regmap *t_map = pvt->t_map; in pvt_read_temp()
302 *val = pvt_calc_temp(pvt, nbs); in pvt_read_temp()
312 struct pvt_device *pvt = dev_get_drvdata(dev); in pvt_read_in() local
313 struct regmap *v_map = pvt->v_map; in pvt_read_in()
318 if (channel >= pvt->vm_channels.total) in pvt_read_in()
321 vm_idx = pvt->vd[channel].vm_map; in pvt_read_in()
322 ch_idx = pvt->vd[channel].ch_map; in pvt_read_in()
338 pre_scaler = pvt->vd[channel].pre_scaler; in pvt_read_in()
389 static int pvt_init(struct pvt_device *pvt) in pvt_init() argument
392 struct regmap *t_map = pvt->t_map; in pvt_init()
393 struct regmap *p_map = pvt->p_map; in pvt_init()
394 struct regmap *v_map = pvt->v_map; in pvt_init()
395 u32 t_num = pvt->t_num; in pvt_init()
396 u32 p_num = pvt->p_num; in pvt_init()
397 u32 v_num = pvt->v_num; in pvt_init()
401 sys_freq = clk_get_rate(pvt->clk) / HZ_PER_MHZ; in pvt_init()
426 pvt->ip_freq = clk_get_rate(pvt->clk) / (key + 2); in pvt_init()
524 val = (BIT(pvt->vm_channels.max) - 1) | VM_CH_INIT | in pvt_init()
582 struct pvt_device *pvt) in pvt_get_regmap() argument
589 reg_map = &pvt->c_map; in pvt_get_regmap()
591 reg_map = &pvt->t_map; in pvt_get_regmap()
593 reg_map = &pvt->p_map; in pvt_get_regmap()
595 reg_map = &pvt->v_map; in pvt_get_regmap()
615 struct pvt_device *pvt = data; in pvt_reset_control_assert() local
617 reset_control_assert(pvt->rst); in pvt_reset_control_assert()
620 static int pvt_reset_control_deassert(struct device *dev, struct pvt_device *pvt) in pvt_reset_control_deassert() argument
624 ret = reset_control_deassert(pvt->rst); in pvt_reset_control_deassert()
628 return devm_add_action_or_reset(dev, pvt_reset_control_assert, pvt); in pvt_reset_control_deassert()
631 static int pvt_get_active_channel(struct device *dev, struct pvt_device *pvt, in pvt_get_active_channel() argument
645 pvt->vm_channels.max = ch_num; in pvt_get_active_channel()
646 pvt->vm_channels.total = ch_num * vm_num; in pvt_get_active_channel()
655 pvt->vm_channels.total += vm_active_ch[i]; in pvt_get_active_channel()
657 if (vm_active_ch[i] > pvt->vm_channels.max) in pvt_get_active_channel()
658 pvt->vm_channels.max = vm_active_ch[i]; in pvt_get_active_channel()
668 pvt->vd = devm_kcalloc(dev, pvt->vm_channels.total, sizeof(*pvt->vd), in pvt_get_active_channel()
670 if (!pvt->vd) in pvt_get_active_channel()
676 pvt->vd[k].vm_map = vm_idx[i]; in pvt_get_active_channel()
677 pvt->vd[k].ch_map = j; in pvt_get_active_channel()
685 static int pvt_get_pre_scaler(struct device *dev, struct pvt_device *pvt) in pvt_get_pre_scaler() argument
692 for (i = 0; i < pvt->vm_channels.total; i++) in pvt_get_pre_scaler()
693 pvt->vd[i].pre_scaler = PRE_SCALER_X1; in pvt_get_pre_scaler()
713 pvt->vd[channel].pre_scaler = PRE_SCALER_X2; in pvt_get_pre_scaler()
722 static int pvt_set_temp_coeff(struct device *dev, struct pvt_device *pvt) in pvt_set_temp_coeff() argument
724 struct temp_coeff *ts_coeff = &pvt->ts_coeff; in pvt_set_temp_coeff()
773 struct pvt_device *pvt; in mr75203_probe() local
776 pvt = devm_kzalloc(dev, sizeof(*pvt), GFP_KERNEL); in mr75203_probe()
777 if (!pvt) in mr75203_probe()
780 ret = pvt_get_regmap(pdev, "common", pvt); in mr75203_probe()
784 pvt->clk = devm_clk_get_enabled(dev, NULL); in mr75203_probe()
785 if (IS_ERR(pvt->clk)) in mr75203_probe()
786 return dev_err_probe(dev, PTR_ERR(pvt->clk), "failed to get clock\n"); in mr75203_probe()
788 pvt->rst = devm_reset_control_get_optional_exclusive(dev, NULL); in mr75203_probe()
789 if (IS_ERR(pvt->rst)) in mr75203_probe()
790 return dev_err_probe(dev, PTR_ERR(pvt->rst), in mr75203_probe()
793 if (pvt->rst) { in mr75203_probe()
794 ret = pvt_reset_control_deassert(dev, pvt); in mr75203_probe()
800 ret = regmap_read(pvt->c_map, PVT_IP_CONFIG, &val); in mr75203_probe()
808 pvt->t_num = ts_num; in mr75203_probe()
809 pvt->p_num = pd_num; in mr75203_probe()
810 pvt->v_num = vm_num; in mr75203_probe()
826 ret = pvt_get_regmap(pdev, "ts", pvt); in mr75203_probe()
830 ret = pvt_set_temp_coeff(dev, pvt); in mr75203_probe()
843 pvt_ts_dbgfs_create(pvt, dev); in mr75203_probe()
847 ret = pvt_get_regmap(pdev, "pd", pvt); in mr75203_probe()
855 ret = pvt_get_regmap(pdev, "vm", pvt); in mr75203_probe()
871 pvt->v_num = i; in mr75203_probe()
877 ret = pvt_get_active_channel(dev, pvt, vm_num, ch_num, vm_idx); in mr75203_probe()
881 ret = pvt_get_pre_scaler(dev, pvt); in mr75203_probe()
885 in_config = devm_kcalloc(dev, pvt->vm_channels.total + 1, in mr75203_probe()
890 memset32(in_config, HWMON_I_INPUT, pvt->vm_channels.total); in mr75203_probe()
891 in_config[pvt->vm_channels.total] = 0; in mr75203_probe()
897 ret = pvt_init(pvt); in mr75203_probe()
905 pvt, in mr75203_probe()