Lines Matching refs:pvt

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