Lines Matching refs:idt82p33
43 static inline int idt82p33_read(struct idt82p33 *idt82p33, u16 regaddr, in idt82p33_read() argument
46 return regmap_bulk_read(idt82p33->regmap, regaddr, buf, count); in idt82p33_read()
49 static inline int idt82p33_write(struct idt82p33 *idt82p33, u16 regaddr, in idt82p33_write() argument
52 return regmap_bulk_write(idt82p33->regmap, regaddr, buf, count); in idt82p33_write()
102 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_dpll_set_mode() local
109 err = idt82p33_read(idt82p33, channel->dpll_mode_cnfg, in idt82p33_dpll_set_mode()
118 err = idt82p33_write(idt82p33, channel->dpll_mode_cnfg, in idt82p33_dpll_set_mode()
131 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_set_tod_trigger() local
138 err = idt82p33_read(idt82p33, channel->dpll_tod_trigger, in idt82p33_set_tod_trigger()
151 return idt82p33_write(idt82p33, channel->dpll_tod_trigger, in idt82p33_set_tod_trigger()
158 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_get_extts() local
162 err = idt82p33_read(idt82p33, channel->dpll_tod_sts, buf, sizeof(buf)); in idt82p33_get_extts()
215 struct idt82p33 *idt82p33 = channel->idt82p33; in arm_tod_read_with_trigger() local
220 err = idt82p33_read(idt82p33, channel->dpll_tod_sts, buf, sizeof(buf)); in arm_tod_read_with_trigger()
230 dev_err(idt82p33->dev, "%s: err = %d", __func__, err); in arm_tod_read_with_trigger()
239 struct idt82p33 *idt82p33; in idt82p33_extts_enable() local
246 idt82p33 = channel->idt82p33; in idt82p33_extts_enable()
247 old_mask = idt82p33->extts_mask; in idt82p33_extts_enable()
266 if (idt82p33->extts_mask & mask) in idt82p33_extts_enable()
273 dev_err(idt82p33->dev, "%s: No valid pin found for Pll%d!\n", in idt82p33_extts_enable()
281 dev_err(idt82p33->dev, in idt82p33_extts_enable()
286 err = arm_tod_read_with_trigger(&idt82p33->channel[index], trigger); in idt82p33_extts_enable()
289 idt82p33->extts_mask |= mask; in idt82p33_extts_enable()
290 idt82p33->channel[index].tod_trigger = trigger; in idt82p33_extts_enable()
291 idt82p33->event_channel[index] = channel; in idt82p33_extts_enable()
292 idt82p33->extts_single_shot = is_one_shot(idt82p33->extts_mask); in idt82p33_extts_enable()
297 schedule_delayed_work(&idt82p33->extts_work, in idt82p33_extts_enable()
301 idt82p33->extts_mask &= ~mask; in idt82p33_extts_enable()
302 idt82p33->extts_single_shot = is_one_shot(idt82p33->extts_mask); in idt82p33_extts_enable()
304 if (idt82p33->extts_mask == 0) in idt82p33_extts_enable()
305 cancel_delayed_work(&idt82p33->extts_work); in idt82p33_extts_enable()
311 static int idt82p33_extts_check_channel(struct idt82p33 *idt82p33, u8 todn) in idt82p33_extts_check_channel() argument
318 err = idt82p33_get_extts(&idt82p33->channel[todn], &ts); in idt82p33_extts_check_channel()
320 event_channel = idt82p33->event_channel[todn]; in idt82p33_extts_check_channel()
333 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_extts_enable_mask() local
343 cancel_delayed_work_sync(&idt82p33->extts_work); in idt82p33_extts_enable_mask()
352 err = arm_tod_read_with_trigger(&idt82p33->channel[i], trigger); in idt82p33_extts_enable_mask()
354 dev_err(idt82p33->dev, in idt82p33_extts_enable_mask()
358 err = idt82p33_extts_check_channel(idt82p33, i); in idt82p33_extts_enable_mask()
359 if (err == 0 && idt82p33->extts_single_shot) in idt82p33_extts_enable_mask()
366 schedule_delayed_work(&idt82p33->extts_work, in idt82p33_extts_enable_mask()
375 struct idt82p33 *idt82p33 = channel->idt82p33; in _idt82p33_gettime() local
376 u8 old_mask = idt82p33->extts_mask; in _idt82p33_gettime()
392 if (idt82p33->calculate_overhead_flag) in _idt82p33_gettime()
393 idt82p33->start_time = ktime_get_raw(); in _idt82p33_gettime()
395 err = idt82p33_read(idt82p33, channel->dpll_tod_sts, buf, sizeof(buf)); in _idt82p33_gettime()
418 struct idt82p33 *idt82p33 = channel->idt82p33; in _idt82p33_settime() local
432 if (idt82p33->calculate_overhead_flag) { in _idt82p33_settime()
434 - ktime_to_ns(idt82p33->start_time); in _idt82p33_settime()
438 idt82p33->calculate_overhead_flag = 0; in _idt82p33_settime()
447 err = idt82p33_write(idt82p33, channel->dpll_tod_cnfg + i, in _idt82p33_settime()
459 struct idt82p33 *idt82p33 = channel->idt82p33; in _idt82p33_adjtime_immediate() local
464 idt82p33->calculate_overhead_flag = 1; in _idt82p33_adjtime_immediate()
472 now_ns += delta_ns + idt82p33->tod_write_overhead_ns; in _idt82p33_adjtime_immediate()
484 struct idt82p33 *idt82p33 = channel->idt82p33; in _idt82p33_adjtime_internal_triggered() local
510 err = idt82p33_write(idt82p33, channel->dpll_tod_cnfg, buf, sizeof(buf)); in _idt82p33_adjtime_internal_triggered()
527 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_adjtime_workaround() local
529 mutex_lock(idt82p33->lock); in idt82p33_adjtime_workaround()
532 mutex_unlock(idt82p33->lock); in idt82p33_adjtime_workaround()
537 struct idt82p33 *idt82p33 = channel->idt82p33; in _idt82p33_adjfine() local
569 err = idt82p33_write(idt82p33, channel->dpll_freq_cnfg, in _idt82p33_adjfine()
641 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_measure_one_byte_write_overhead() local
655 err = idt82p33_write(idt82p33, channel->dpll_tod_trigger, in idt82p33_measure_one_byte_write_overhead()
674 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_measure_one_byte_read_overhead() local
688 err = idt82p33_read(idt82p33, channel->dpll_tod_trigger, in idt82p33_measure_one_byte_read_overhead()
707 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_measure_tod_write_9_byte_overhead() local
715 idt82p33->tod_write_overhead_ns = 0; in idt82p33_measure_tod_write_9_byte_overhead()
723 err = idt82p33_write(idt82p33, in idt82p33_measure_tod_write_9_byte_overhead()
735 idt82p33->tod_write_overhead_ns = div_s64(total_ns, in idt82p33_measure_tod_write_9_byte_overhead()
766 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_measure_tod_write_overhead() local
769 idt82p33->tod_write_overhead_ns = 0; in idt82p33_measure_tod_write_overhead()
774 dev_err(idt82p33->dev, in idt82p33_measure_tod_write_overhead()
799 idt82p33->tod_write_overhead_ns -= trailing_overhead_ns; in idt82p33_measure_tod_write_overhead()
804 static int idt82p33_check_and_set_masks(struct idt82p33 *idt82p33, in idt82p33_check_and_set_masks() argument
813 dev_err(idt82p33->dev, in idt82p33_check_and_set_masks()
817 idt82p33->pll_mask = val; in idt82p33_check_and_set_masks()
821 idt82p33->channel[0].output_mask = val; in idt82p33_check_and_set_masks()
824 idt82p33->channel[1].output_mask = val; in idt82p33_check_and_set_masks()
830 static void idt82p33_display_masks(struct idt82p33 *idt82p33) in idt82p33_display_masks() argument
834 dev_info(idt82p33->dev, in idt82p33_display_masks()
835 "pllmask = 0x%02x\n", idt82p33->pll_mask); in idt82p33_display_masks()
840 if (mask & idt82p33->pll_mask) in idt82p33_display_masks()
841 dev_info(idt82p33->dev, in idt82p33_display_masks()
843 i, idt82p33->channel[i].output_mask); in idt82p33_display_masks()
849 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_sync_tod() local
853 err = idt82p33_read(idt82p33, channel->dpll_sync_cnfg, in idt82p33_sync_tod()
862 return idt82p33_write(idt82p33, channel->dpll_sync_cnfg, in idt82p33_sync_tod()
870 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_work_handler() local
872 mutex_lock(idt82p33->lock); in idt82p33_work_handler()
874 mutex_unlock(idt82p33->lock); in idt82p33_work_handler()
883 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_output_enable() local
887 err = idt82p33_read(idt82p33, OUT_MUX_CNFG(outn), &val, sizeof(val)); in idt82p33_output_enable()
895 return idt82p33_write(idt82p33, OUT_MUX_CNFG(outn), &val, sizeof(val)); in idt82p33_output_enable()
908 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_enable_tod() local
915 dev_err(idt82p33->dev, in idt82p33_enable_tod()
928 static void idt82p33_ptp_clock_unregister_all(struct idt82p33 *idt82p33) in idt82p33_ptp_clock_unregister_all() argument
934 channel = &idt82p33->channel[i]; in idt82p33_ptp_clock_unregister_all()
948 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_enable() local
951 mutex_lock(idt82p33->lock); in idt82p33_enable()
973 mutex_unlock(idt82p33->lock); in idt82p33_enable()
976 dev_err(idt82p33->dev, in idt82p33_enable()
990 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_adjwritephase() local
1005 mutex_lock(idt82p33->lock); in idt82p33_adjwritephase()
1009 dev_err(idt82p33->dev, in idt82p33_adjwritephase()
1014 err = idt82p33_write(idt82p33, channel->dpll_phase_cnfg, val, in idt82p33_adjwritephase()
1018 mutex_unlock(idt82p33->lock); in idt82p33_adjwritephase()
1026 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_adjfine() local
1035 mutex_lock(idt82p33->lock); in idt82p33_adjfine()
1040 mutex_unlock(idt82p33->lock); in idt82p33_adjfine()
1043 dev_err(idt82p33->dev, in idt82p33_adjfine()
1052 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_adjtime() local
1058 mutex_lock(idt82p33->lock); in idt82p33_adjtime()
1062 mutex_unlock(idt82p33->lock); in idt82p33_adjtime()
1071 mutex_unlock(idt82p33->lock); in idt82p33_adjtime()
1074 dev_err(idt82p33->dev, in idt82p33_adjtime()
1083 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_gettime() local
1086 mutex_lock(idt82p33->lock); in idt82p33_gettime()
1088 mutex_unlock(idt82p33->lock); in idt82p33_gettime()
1091 dev_err(idt82p33->dev, in idt82p33_gettime()
1101 struct idt82p33 *idt82p33 = channel->idt82p33; in idt82p33_settime() local
1104 mutex_lock(idt82p33->lock); in idt82p33_settime()
1106 mutex_unlock(idt82p33->lock); in idt82p33_settime()
1109 dev_err(idt82p33->dev, in idt82p33_settime()
1114 static int idt82p33_channel_init(struct idt82p33 *idt82p33, u32 index) in idt82p33_channel_init() argument
1116 struct idt82p33_channel *channel = &idt82p33->channel[index]; in idt82p33_channel_init()
1145 channel->idt82p33 = idt82p33; in idt82p33_channel_init()
1200 static int idt82p33_enable_channel(struct idt82p33 *idt82p33, u32 index) in idt82p33_enable_channel() argument
1208 channel = &idt82p33->channel[index]; in idt82p33_enable_channel()
1210 err = idt82p33_channel_init(idt82p33, index); in idt82p33_enable_channel()
1212 dev_err(idt82p33->dev, in idt82p33_enable_channel()
1234 dev_err(idt82p33->dev, in idt82p33_enable_channel()
1242 dev_err(idt82p33->dev, in idt82p33_enable_channel()
1248 dev_info(idt82p33->dev, "PLL%d registered as ptp%d\n", in idt82p33_enable_channel()
1254 static int idt82p33_reset(struct idt82p33 *idt82p33, bool cold) in idt82p33_reset() argument
1262 err = idt82p33_read(idt82p33, REG_SOFT_RESET, &cfg, sizeof(cfg)); in idt82p33_reset()
1264 dev_err(idt82p33->dev, in idt82p33_reset()
1272 err = idt82p33_write(idt82p33, REG_SOFT_RESET, &cfg, sizeof(cfg)); in idt82p33_reset()
1274 dev_err(idt82p33->dev, in idt82p33_reset()
1279 static int idt82p33_load_firmware(struct idt82p33 *idt82p33) in idt82p33_load_firmware() argument
1291 dev_info(idt82p33->dev, "requesting firmware '%s'\n", fname); in idt82p33_load_firmware()
1293 err = request_firmware(&fw, fname, idt82p33->dev); in idt82p33_load_firmware()
1296 dev_err(idt82p33->dev, in idt82p33_load_firmware()
1301 dev_dbg(idt82p33->dev, "firmware size %zu bytes\n", fw->size); in idt82p33_load_firmware()
1308 dev_err(idt82p33->dev, in idt82p33_load_firmware()
1318 err = idt82p33_check_and_set_masks(idt82p33, page, in idt82p33_load_firmware()
1327 err = idt82p33_write(idt82p33, REG_ADDR(page, loaddr), in idt82p33_load_firmware()
1335 idt82p33_display_masks(idt82p33); in idt82p33_load_firmware()
1343 struct idt82p33 *idt82p33 = container_of(work, struct idt82p33, in idt82p33_extts_check() local
1350 if (idt82p33->extts_mask == 0) in idt82p33_extts_check()
1353 mutex_lock(idt82p33->lock); in idt82p33_extts_check()
1358 if ((idt82p33->extts_mask & mask) == 0) in idt82p33_extts_check()
1361 err = idt82p33_extts_check_channel(idt82p33, i); in idt82p33_extts_check()
1365 if (idt82p33->extts_single_shot) { in idt82p33_extts_check()
1366 idt82p33->extts_mask &= ~mask; in idt82p33_extts_check()
1369 channel = &idt82p33->channel[i]; in idt82p33_extts_check()
1375 if (idt82p33->extts_mask) in idt82p33_extts_check()
1376 schedule_delayed_work(&idt82p33->extts_work, in idt82p33_extts_check()
1379 mutex_unlock(idt82p33->lock); in idt82p33_extts_check()
1385 struct idt82p33 *idt82p33; in idt82p33_probe() local
1389 idt82p33 = devm_kzalloc(&pdev->dev, in idt82p33_probe()
1390 sizeof(struct idt82p33), GFP_KERNEL); in idt82p33_probe()
1391 if (!idt82p33) in idt82p33_probe()
1394 idt82p33->dev = &pdev->dev; in idt82p33_probe()
1395 idt82p33->mfd = pdev->dev.parent; in idt82p33_probe()
1396 idt82p33->lock = &ddata->lock; in idt82p33_probe()
1397 idt82p33->regmap = ddata->regmap; in idt82p33_probe()
1398 idt82p33->tod_write_overhead_ns = 0; in idt82p33_probe()
1399 idt82p33->calculate_overhead_flag = 0; in idt82p33_probe()
1400 idt82p33->pll_mask = DEFAULT_PLL_MASK; in idt82p33_probe()
1401 idt82p33->channel[0].output_mask = DEFAULT_OUTPUT_MASK_PLL0; in idt82p33_probe()
1402 idt82p33->channel[1].output_mask = DEFAULT_OUTPUT_MASK_PLL1; in idt82p33_probe()
1403 idt82p33->extts_mask = 0; in idt82p33_probe()
1404 INIT_DELAYED_WORK(&idt82p33->extts_work, idt82p33_extts_check); in idt82p33_probe()
1406 mutex_lock(idt82p33->lock); in idt82p33_probe()
1409 idt82p33_reset(idt82p33, true); in idt82p33_probe()
1411 err = idt82p33_load_firmware(idt82p33); in idt82p33_probe()
1413 dev_warn(idt82p33->dev, in idt82p33_probe()
1417 idt82p33_reset(idt82p33, false); in idt82p33_probe()
1419 if (idt82p33->pll_mask) { in idt82p33_probe()
1421 if (idt82p33->pll_mask & (1 << i)) in idt82p33_probe()
1422 err = idt82p33_enable_channel(idt82p33, i); in idt82p33_probe()
1424 err = idt82p33_channel_init(idt82p33, i); in idt82p33_probe()
1426 dev_err(idt82p33->dev, in idt82p33_probe()
1433 dev_err(idt82p33->dev, in idt82p33_probe()
1438 mutex_unlock(idt82p33->lock); in idt82p33_probe()
1441 idt82p33_ptp_clock_unregister_all(idt82p33); in idt82p33_probe()
1445 platform_set_drvdata(pdev, idt82p33); in idt82p33_probe()
1452 struct idt82p33 *idt82p33 = platform_get_drvdata(pdev); in idt82p33_remove() local
1454 cancel_delayed_work_sync(&idt82p33->extts_work); in idt82p33_remove()
1456 idt82p33_ptp_clock_unregister_all(idt82p33); in idt82p33_remove()