Lines Matching refs:pvt

188 	struct pvt_device *pvt = file->private_data;
192 len = scnprintf(buf, sizeof(buf), "%d\n", pvt->ts_coeff.j);
201 struct pvt_device *pvt = file->private_data;
204 ret = kstrtos32_from_user(user_buf, count, 0, &pvt->ts_coeff.j);
221 struct pvt_device *pvt = (struct pvt_device *)data;
223 debugfs_remove_recursive(pvt->dbgfs_dir);
224 pvt->dbgfs_dir = NULL;
227 static int pvt_ts_dbgfs_create(struct pvt_device *pvt, struct device *dev)
229 pvt->dbgfs_dir = debugfs_create_dir(dev_name(dev), NULL);
231 debugfs_create_u32("ts_coeff_h", 0644, pvt->dbgfs_dir,
232 &pvt->ts_coeff.h);
233 debugfs_create_u32("ts_coeff_g", 0644, pvt->dbgfs_dir,
234 &pvt->ts_coeff.g);
235 debugfs_create_u32("ts_coeff_cal5", 0644, pvt->dbgfs_dir,
236 &pvt->ts_coeff.cal5);
237 debugfs_create_file("ts_coeff_j", 0644, pvt->dbgfs_dir, pvt,
240 return devm_add_action_or_reset(dev, devm_pvt_ts_dbgfs_remove, pvt);
261 static long pvt_calc_temp(struct pvt_device *pvt, u32 nbs)
267 struct temp_coeff *ts_coeff = &pvt->ts_coeff;
272 div_s64(ts_coeff->j * (s64)pvt->ip_freq, HZ_PER_MHZ);
279 struct pvt_device *pvt = dev_get_drvdata(dev);
280 struct regmap *t_map = pvt->t_map;
303 *val = pvt_calc_temp(pvt, nbs);
313 struct pvt_device *pvt = dev_get_drvdata(dev);
314 struct regmap *v_map = pvt->v_map;
319 if (channel >= pvt->vm_channels.total)
322 vm_idx = pvt->vd[channel].vm_map;
323 ch_idx = pvt->vd[channel].ch_map;
339 pre_scaler = pvt->vd[channel].pre_scaler;
390 static int pvt_init(struct pvt_device *pvt)
393 struct regmap *t_map = pvt->t_map;
394 struct regmap *p_map = pvt->p_map;
395 struct regmap *v_map = pvt->v_map;
396 u32 t_num = pvt->t_num;
397 u32 p_num = pvt->p_num;
398 u32 v_num = pvt->v_num;
402 sys_freq = clk_get_rate(pvt->clk) / HZ_PER_MHZ;
427 pvt->ip_freq = clk_get_rate(pvt->clk) / (key + 2);
525 val = (BIT(pvt->vm_channels.max) - 1) | VM_CH_INIT |
583 struct pvt_device *pvt)
590 reg_map = &pvt->c_map;
592 reg_map = &pvt->t_map;
594 reg_map = &pvt->p_map;
596 reg_map = &pvt->v_map;
616 struct pvt_device *pvt = data;
618 reset_control_assert(pvt->rst);
621 static int pvt_reset_control_deassert(struct device *dev, struct pvt_device *pvt)
625 ret = reset_control_deassert(pvt->rst);
629 return devm_add_action_or_reset(dev, pvt_reset_control_assert, pvt);
632 static int pvt_get_active_channel(struct device *dev, struct pvt_device *pvt,
646 pvt->vm_channels.max = ch_num;
647 pvt->vm_channels.total = ch_num * vm_num;
656 pvt->vm_channels.total += vm_active_ch[i];
658 if (vm_active_ch[i] > pvt->vm_channels.max)
659 pvt->vm_channels.max = vm_active_ch[i];
669 pvt->vd = devm_kcalloc(dev, pvt->vm_channels.total, sizeof(*pvt->vd),
671 if (!pvt->vd)
677 pvt->vd[k].vm_map = vm_idx[i];
678 pvt->vd[k].ch_map = j;
686 static int pvt_get_pre_scaler(struct device *dev, struct pvt_device *pvt)
693 for (i = 0; i < pvt->vm_channels.total; i++)
694 pvt->vd[i].pre_scaler = PRE_SCALER_X1;
714 pvt->vd[channel].pre_scaler = PRE_SCALER_X2;
723 static int pvt_set_temp_coeff(struct device *dev, struct pvt_device *pvt)
725 struct temp_coeff *ts_coeff = &pvt->ts_coeff;
774 struct pvt_device *pvt;
777 pvt = devm_kzalloc(dev, sizeof(*pvt), GFP_KERNEL);
778 if (!pvt)
781 ret = pvt_get_regmap(pdev, "common", pvt);
785 pvt->clk = devm_clk_get_enabled(dev, NULL);
786 if (IS_ERR(pvt->clk))
787 return dev_err_probe(dev, PTR_ERR(pvt->clk), "failed to get clock\n");
789 pvt->rst = devm_reset_control_get_optional_exclusive(dev, NULL);
790 if (IS_ERR(pvt->rst))
791 return dev_err_probe(dev, PTR_ERR(pvt->rst),
794 if (pvt->rst) {
795 ret = pvt_reset_control_deassert(dev, pvt);
801 ret = regmap_read(pvt->c_map, PVT_IP_CONFIG, &val);
809 pvt->t_num = ts_num;
810 pvt->p_num = pd_num;
811 pvt->v_num = vm_num;
827 ret = pvt_get_regmap(pdev, "ts", pvt);
831 ret = pvt_set_temp_coeff(dev, pvt);
844 pvt_ts_dbgfs_create(pvt, dev);
848 ret = pvt_get_regmap(pdev, "pd", pvt);
856 ret = pvt_get_regmap(pdev, "vm", pvt);
872 pvt->v_num = i;
878 ret = pvt_get_active_channel(dev, pvt, vm_num, ch_num, vm_idx);
882 ret = pvt_get_pre_scaler(dev, pvt);
886 in_config = devm_kcalloc(dev, pvt->vm_channels.total + 1,
891 memset32(in_config, HWMON_I_INPUT, pvt->vm_channels.total);
892 in_config[pvt->vm_channels.total] = 0;
898 ret = pvt_init(pvt);
900 dev_err(dev, "failed to init pvt: %d\n", ret);
905 hwmon_dev = devm_hwmon_device_register_with_info(dev, "pvt",
906 pvt,
921 .name = "moortec-pvt",