Lines Matching +full:refclk +full:- +full:mux
1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com
9 #include <linux/clk-provider.h>
23 #include "am65-cpts.h"
164 struct clk *refclk; member
201 #define am65_cpts_write32(c, v, r) writel(v, &(c)->reg->r)
202 #define am65_cpts_read32(c, r) readl(&(c)->reg->r)
219 cpts->ts_add_val = (NSEC_PER_SEC / cpts->refclk_freq - 1) & 0x7; in am65_cpts_set_add_val()
221 am65_cpts_write32(cpts, cpts->ts_add_val, ts_add_val); in am65_cpts_set_add_val()
232 return (event->event1 & AM65_CPTS_EVENT_1_PORT_NUMBER_MASK) >> in am65_cpts_event_get_port()
238 return (event->event1 & AM65_CPTS_EVENT_1_EVENT_TYPE_MASK) >> in am65_cpts_event_get_type()
248 list_for_each_safe(this, next, &cpts->events) { in am65_cpts_cpts_purge_events()
250 if (time_after(jiffies, event->tmo)) { in am65_cpts_cpts_purge_events()
251 list_del_init(&event->list); in am65_cpts_cpts_purge_events()
252 list_add(&event->list, &cpts->pool); in am65_cpts_cpts_purge_events()
258 dev_dbg(cpts->dev, "event pool cleaned up %d\n", removed); in am65_cpts_cpts_purge_events()
259 return removed ? 0 : -1; in am65_cpts_cpts_purge_events()
268 event->timestamp = am65_cpts_read32(cpts, event_0); in am65_cpts_fifo_pop_event()
269 event->event1 = am65_cpts_read32(cpts, event_1); in am65_cpts_fifo_pop_event()
270 event->event2 = am65_cpts_read32(cpts, event_2); in am65_cpts_fifo_pop_event()
271 event->timestamp |= (u64)am65_cpts_read32(cpts, event_3) << 32; in am65_cpts_fifo_pop_event()
286 spin_lock_irqsave(&cpts->lock, flags); in am65_cpts_fifo_read()
288 event = list_first_entry_or_null(&cpts->pool, in am65_cpts_fifo_read()
293 dev_err(cpts->dev, "cpts: event pool empty\n"); in am65_cpts_fifo_read()
294 ret = -1; in am65_cpts_fifo_read()
306 cpts->timestamp = event->timestamp; in am65_cpts_fifo_read()
307 dev_dbg(cpts->dev, "AM65_CPTS_EV_PUSH t:%llu\n", in am65_cpts_fifo_read()
308 cpts->timestamp); in am65_cpts_fifo_read()
312 event->tmo = jiffies + in am65_cpts_fifo_read()
315 list_del_init(&event->list); in am65_cpts_fifo_read()
316 list_add_tail(&event->list, &cpts->events); in am65_cpts_fifo_read()
318 dev_dbg(cpts->dev, in am65_cpts_fifo_read()
320 event->event1, event->event2, in am65_cpts_fifo_read()
321 event->timestamp); in am65_cpts_fifo_read()
325 pevent.index = am65_cpts_event_get_port(event) - 1; in am65_cpts_fifo_read()
326 pevent.timestamp = event->timestamp; in am65_cpts_fifo_read()
327 if (cpts->pps_enabled && pevent.index == cpts->pps_hw_ts_idx) { in am65_cpts_fifo_read()
333 dev_dbg(cpts->dev, "AM65_CPTS_EV_HW:%s p:%d t:%llu\n", in am65_cpts_fifo_read()
336 pevent.index, event->timestamp); in am65_cpts_fifo_read()
338 ptp_clock_event(cpts->ptp_clock, &pevent); in am65_cpts_fifo_read()
345 dev_dbg(cpts->dev, in am65_cpts_fifo_read()
348 event->event1, event->event2, in am65_cpts_fifo_read()
349 event->timestamp); in am65_cpts_fifo_read()
352 dev_err(cpts->dev, "cpts: unknown event type\n"); in am65_cpts_fifo_read()
353 ret = -1; in am65_cpts_fifo_read()
359 spin_unlock_irqrestore(&cpts->lock, flags); in am65_cpts_fifo_read()
362 ptp_schedule_worker(cpts->ptp_clock, 0); in am65_cpts_fifo_read()
374 * doubled read. Interrupt can be in-flight - it's Ok. in am65_cpts_gettime()
379 spin_lock_irqsave(&cpts->lock, flags); in am65_cpts_gettime()
384 spin_unlock_irqrestore(&cpts->lock, flags); in am65_cpts_gettime()
390 val = cpts->timestamp; in am65_cpts_gettime()
400 dev_dbg(cpts->dev, "cpts: unable to obtain a time stamp\n"); in am65_cpts_interrupt()
411 int pps_index = cpts->pps_genf_idx; in am65_cpts_ptp_adjfine()
419 ppb = -ppb; in am65_cpts_ptp_adjfine()
431 adj_period = div_u64(cpts->refclk_freq, ppb); in am65_cpts_ptp_adjfine()
433 mutex_lock(&cpts->ptp_clk_lock); in am65_cpts_ptp_adjfine()
444 if (cpts->pps_enabled) { in am65_cpts_ptp_adjfine()
451 /* GenF PPM will do correction using cpts refclk tick which is in am65_cpts_ptp_adjfine()
452 * (cpts->ts_add_val + 1) ns, so GenF length PPM adj period in am65_cpts_ptp_adjfine()
455 pps_adj_period = adj_period * (cpts->ts_add_val + 1); in am65_cpts_ptp_adjfine()
460 spin_lock_irqsave(&cpts->lock, flags); in am65_cpts_ptp_adjfine()
463 * - delay between PPM dir and PPM value changes can cause err due old in am65_cpts_ptp_adjfine()
465 * - delay between CPTS-clock PPM cfg and GenF PPM cfg can cause err in am65_cpts_ptp_adjfine()
466 * due CPTS-clock PPM working with new cfg while GenF PPM cfg still in am65_cpts_ptp_adjfine()
474 if (cpts->pps_enabled) { in am65_cpts_ptp_adjfine()
481 if (cpts->estf_enable & BIT(i)) { in am65_cpts_ptp_adjfine()
488 spin_unlock_irqrestore(&cpts->lock, flags); in am65_cpts_ptp_adjfine()
490 mutex_unlock(&cpts->ptp_clk_lock); in am65_cpts_ptp_adjfine()
500 mutex_lock(&cpts->ptp_clk_lock); in am65_cpts_ptp_adjtime()
504 mutex_unlock(&cpts->ptp_clk_lock); in am65_cpts_ptp_adjtime()
516 mutex_lock(&cpts->ptp_clk_lock); in am65_cpts_ptp_gettimex()
518 mutex_unlock(&cpts->ptp_clk_lock); in am65_cpts_ptp_gettimex()
529 mutex_lock(&cpts->ptp_clk_lock); in am65_cpts_ns_gettime()
531 mutex_unlock(&cpts->ptp_clk_lock); in am65_cpts_ns_gettime()
544 mutex_lock(&cpts->ptp_clk_lock); in am65_cpts_ptp_settime()
546 mutex_unlock(&cpts->ptp_clk_lock); in am65_cpts_ptp_settime()
558 cpts->hw_ts_enable |= BIT(index); in am65_cpts_extts_enable_hw()
561 cpts->hw_ts_enable &= ~BIT(index); in am65_cpts_extts_enable_hw()
568 if (index >= cpts->ptp_info.n_ext_ts) in am65_cpts_extts_enable()
569 return -ENXIO; in am65_cpts_extts_enable()
571 if (cpts->pps_present && index == cpts->pps_hw_ts_idx) in am65_cpts_extts_enable()
572 return -EINVAL; in am65_cpts_extts_enable()
574 if (((cpts->hw_ts_enable & BIT(index)) >> index) == on) in am65_cpts_extts_enable()
577 mutex_lock(&cpts->ptp_clk_lock); in am65_cpts_extts_enable()
579 mutex_unlock(&cpts->ptp_clk_lock); in am65_cpts_extts_enable()
581 dev_dbg(cpts->dev, "%s: ExtTS:%u %s\n", in am65_cpts_extts_enable()
593 cycles = cfg->ns_period * cpts->refclk_freq; in am65_cpts_estf_enable()
596 return -EINVAL; in am65_cpts_estf_enable()
601 val = upper_32_bits(cfg->ns_start); in am65_cpts_estf_enable()
603 val = lower_32_bits(cfg->ns_start); in am65_cpts_estf_enable()
611 cpts->estf_enable |= BIT(idx); in am65_cpts_estf_enable()
613 dev_dbg(cpts->dev, "%s: ESTF:%u enabled\n", __func__, idx); in am65_cpts_estf_enable()
622 cpts->estf_enable &= ~BIT(idx); in am65_cpts_estf_disable()
624 dev_dbg(cpts->dev, "%s: ESTF:%u disabled\n", __func__, idx); in am65_cpts_estf_disable()
636 ts.tv_sec = req->period.sec; in am65_cpts_perout_enable_hw()
637 ts.tv_nsec = req->period.nsec; in am65_cpts_perout_enable_hw()
640 cycles = (ns_period * cpts->refclk_freq) / NSEC_PER_SEC; in am65_cpts_perout_enable_hw()
642 ts.tv_sec = req->start.sec; in am65_cpts_perout_enable_hw()
643 ts.tv_nsec = req->start.nsec; in am65_cpts_perout_enable_hw()
647 am65_cpts_write32(cpts, val, genf[req->index].comp_hi); in am65_cpts_perout_enable_hw()
649 am65_cpts_write32(cpts, val, genf[req->index].comp_lo); in am65_cpts_perout_enable_hw()
651 am65_cpts_write32(cpts, val, genf[req->index].length); in am65_cpts_perout_enable_hw()
653 am65_cpts_write32(cpts, 0, genf[req->index].control); in am65_cpts_perout_enable_hw()
654 am65_cpts_write32(cpts, 0, genf[req->index].ppm_hi); in am65_cpts_perout_enable_hw()
655 am65_cpts_write32(cpts, 0, genf[req->index].ppm_low); in am65_cpts_perout_enable_hw()
657 cpts->genf_enable |= BIT(req->index); in am65_cpts_perout_enable_hw()
659 am65_cpts_write32(cpts, 0, genf[req->index].length); in am65_cpts_perout_enable_hw()
661 cpts->genf_enable &= ~BIT(req->index); in am65_cpts_perout_enable_hw()
668 if (req->index >= cpts->ptp_info.n_per_out) in am65_cpts_perout_enable()
669 return -ENXIO; in am65_cpts_perout_enable()
671 if (cpts->pps_present && req->index == cpts->pps_genf_idx) in am65_cpts_perout_enable()
672 return -EINVAL; in am65_cpts_perout_enable()
674 if (!!(cpts->genf_enable & BIT(req->index)) == !!on) in am65_cpts_perout_enable()
677 mutex_lock(&cpts->ptp_clk_lock); in am65_cpts_perout_enable()
679 mutex_unlock(&cpts->ptp_clk_lock); in am65_cpts_perout_enable()
681 dev_dbg(cpts->dev, "%s: GenF:%u %s\n", in am65_cpts_perout_enable()
682 __func__, req->index, on ? "enabled" : "disabled"); in am65_cpts_perout_enable()
694 if (!cpts->pps_present) in am65_cpts_pps_enable()
695 return -EINVAL; in am65_cpts_pps_enable()
697 if (cpts->pps_enabled == !!on) in am65_cpts_pps_enable()
700 mutex_lock(&cpts->ptp_clk_lock); in am65_cpts_pps_enable()
703 am65_cpts_extts_enable_hw(cpts, cpts->pps_hw_ts_idx, on); in am65_cpts_pps_enable()
711 rq.perout.index = cpts->pps_genf_idx; in am65_cpts_pps_enable()
714 cpts->pps_enabled = true; in am65_cpts_pps_enable()
716 rq.perout.index = cpts->pps_genf_idx; in am65_cpts_pps_enable()
718 am65_cpts_extts_enable_hw(cpts, cpts->pps_hw_ts_idx, on); in am65_cpts_pps_enable()
719 cpts->pps_enabled = false; in am65_cpts_pps_enable()
722 mutex_unlock(&cpts->ptp_clk_lock); in am65_cpts_pps_enable()
724 dev_dbg(cpts->dev, "%s: pps: %s\n", in am65_cpts_pps_enable()
734 switch (rq->type) { in am65_cpts_ptp_enable()
736 return am65_cpts_extts_enable(cpts, rq->extts.index, on); in am65_cpts_ptp_enable()
738 return am65_cpts_perout_enable(cpts, &rq->perout, on); in am65_cpts_ptp_enable()
745 return -EOPNOTSUPP; in am65_cpts_ptp_enable()
770 mtype_seqid = event->event1 & in am65_cpts_match_tx_ts()
777 spin_lock_irqsave(&cpts->txq.lock, flags); in am65_cpts_match_tx_ts()
778 skb_queue_splice_init(&cpts->txq, &txq_list); in am65_cpts_match_tx_ts()
779 spin_unlock_irqrestore(&cpts->txq.lock, flags); in am65_cpts_match_tx_ts()
781 /* no need to grab txq.lock as access is always done under cpts->lock */ in am65_cpts_match_tx_ts()
785 (struct am65_cpts_skb_cb_data *)skb->cb; in am65_cpts_match_tx_ts()
789 (skb_cb->skb_mtype_seqid & AM65_CPTS_EVENT_1_SEQUENCE_ID_MASK))) in am65_cpts_match_tx_ts()
790 mtype_seqid = skb_cb->skb_mtype_seqid; in am65_cpts_match_tx_ts()
792 if (mtype_seqid == skb_cb->skb_mtype_seqid) { in am65_cpts_match_tx_ts()
793 u64 ns = event->timestamp; in am65_cpts_match_tx_ts()
801 dev_dbg(cpts->dev, in am65_cpts_match_tx_ts()
807 if (time_after(jiffies, skb_cb->tmo)) { in am65_cpts_match_tx_ts()
809 dev_dbg(cpts->dev, in am65_cpts_match_tx_ts()
817 spin_lock_irqsave(&cpts->txq.lock, flags); in am65_cpts_match_tx_ts()
818 skb_queue_splice(&txq_list, &cpts->txq); in am65_cpts_match_tx_ts()
819 spin_unlock_irqrestore(&cpts->txq.lock, flags); in am65_cpts_match_tx_ts()
832 spin_lock_irqsave(&cpts->lock, flags); in am65_cpts_find_ts()
833 list_splice_init(&cpts->events, &events); in am65_cpts_find_ts()
834 spin_unlock_irqrestore(&cpts->lock, flags); in am65_cpts_find_ts()
839 time_after(jiffies, event->tmo)) { in am65_cpts_find_ts()
840 list_del_init(&event->list); in am65_cpts_find_ts()
841 list_add(&event->list, &events_free); in am65_cpts_find_ts()
845 spin_lock_irqsave(&cpts->lock, flags); in am65_cpts_find_ts()
846 list_splice_tail(&events, &cpts->events); in am65_cpts_find_ts()
847 list_splice_tail(&events_free, &cpts->pool); in am65_cpts_find_ts()
848 spin_unlock_irqrestore(&cpts->lock, flags); in am65_cpts_find_ts()
855 long delay = -1; in am65_cpts_ts_work()
859 spin_lock_irqsave(&cpts->txq.lock, flags); in am65_cpts_ts_work()
860 if (!skb_queue_empty(&cpts->txq)) in am65_cpts_ts_work()
862 spin_unlock_irqrestore(&cpts->txq.lock, flags); in am65_cpts_ts_work()
868 * am65_cpts_rx_enable - enable rx timestamping
879 mutex_lock(&cpts->ptp_clk_lock); in am65_cpts_rx_enable()
886 mutex_unlock(&cpts->ptp_clk_lock); in am65_cpts_rx_enable()
905 seqid = ntohs(hdr->sequence_id); in am65_skb_get_mtype_seqid()
915 * am65_cpts_tx_timestamp - save tx packet for timestamping
924 struct am65_cpts_skb_cb_data *skb_cb = (void *)skb->cb; in am65_cpts_tx_timestamp()
926 if (!(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) in am65_cpts_tx_timestamp()
934 skb_cb->tmo = jiffies + msecs_to_jiffies(100); in am65_cpts_tx_timestamp()
935 skb_queue_tail(&cpts->txq, skb); in am65_cpts_tx_timestamp()
936 ptp_schedule_worker(cpts->ptp_clock, 0); in am65_cpts_tx_timestamp()
941 * am65_cpts_prep_tx_timestamp - check and prepare tx packet for timestamping
947 * in skb-cb and marks packet as SKBTX_IN_PROGRESS.
951 struct am65_cpts_skb_cb_data *skb_cb = (void *)skb->cb; in am65_cpts_prep_tx_timestamp()
954 if (!(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) in am65_cpts_prep_tx_timestamp()
957 ret = am65_skb_get_mtype_seqid(skb, &skb_cb->skb_mtype_seqid); in am65_cpts_prep_tx_timestamp()
960 skb_cb->skb_mtype_seqid |= (AM65_CPTS_EV_TX << in am65_cpts_prep_tx_timestamp()
963 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in am65_cpts_prep_tx_timestamp()
969 return cpts->phc_index; in am65_cpts_phc_index()
977 of_clk_del_provider(cpts->clk_mux_np); in cpts_free_clk_mux()
978 clk_hw_unregister_mux(cpts->clk_mux_hw); in cpts_free_clk_mux()
979 of_node_put(cpts->clk_mux_np); in cpts_free_clk_mux()
989 int ret = -EINVAL; in cpts_of_mux_clk_setup()
991 cpts->clk_mux_np = of_get_child_by_name(node, "refclk-mux"); in cpts_of_mux_clk_setup()
992 if (!cpts->clk_mux_np) in cpts_of_mux_clk_setup()
995 num_parents = of_clk_get_parent_count(cpts->clk_mux_np); in cpts_of_mux_clk_setup()
997 dev_err(cpts->dev, "mux-clock %pOF must have parents\n", in cpts_of_mux_clk_setup()
998 cpts->clk_mux_np); in cpts_of_mux_clk_setup()
1002 parent_names = devm_kcalloc(cpts->dev, sizeof(char *), num_parents, in cpts_of_mux_clk_setup()
1005 ret = -ENOMEM; in cpts_of_mux_clk_setup()
1009 of_clk_parent_fill(cpts->clk_mux_np, parent_names, num_parents); in cpts_of_mux_clk_setup()
1011 clk_mux_name = devm_kasprintf(cpts->dev, GFP_KERNEL, "%s.%pOFn", in cpts_of_mux_clk_setup()
1012 dev_name(cpts->dev), cpts->clk_mux_np); in cpts_of_mux_clk_setup()
1014 ret = -ENOMEM; in cpts_of_mux_clk_setup()
1018 reg = &cpts->reg->rftclk_sel; in cpts_of_mux_clk_setup()
1022 cpts->clk_mux_hw = clk_hw_register_mux(NULL, clk_mux_name, in cpts_of_mux_clk_setup()
1025 if (IS_ERR(cpts->clk_mux_hw)) { in cpts_of_mux_clk_setup()
1026 ret = PTR_ERR(cpts->clk_mux_hw); in cpts_of_mux_clk_setup()
1030 ret = of_clk_add_hw_provider(cpts->clk_mux_np, of_clk_hw_simple_get, in cpts_of_mux_clk_setup()
1031 cpts->clk_mux_hw); in cpts_of_mux_clk_setup()
1035 ret = devm_add_action_or_reset(cpts->dev, cpts_free_clk_mux, cpts); in cpts_of_mux_clk_setup()
1037 dev_err(cpts->dev, "failed to add clkmux reset action %d", ret); in cpts_of_mux_clk_setup()
1042 clk_hw_unregister_mux(cpts->clk_mux_hw); in cpts_of_mux_clk_setup()
1044 of_node_put(cpts->clk_mux_np); in cpts_of_mux_clk_setup()
1052 if (!of_property_read_u32(node, "ti,cpts-ext-ts-inputs", &prop[0])) in am65_cpts_of_parse()
1053 cpts->ext_ts_inputs = prop[0]; in am65_cpts_of_parse()
1055 if (!of_property_read_u32(node, "ti,cpts-periodic-outputs", &prop[0])) in am65_cpts_of_parse()
1056 cpts->genf_num = prop[0]; in am65_cpts_of_parse()
1059 cpts->pps_present = true; in am65_cpts_of_parse()
1062 dev_err(cpts->dev, "invalid HWx_TS_PUSH index: %u provided\n", prop[0]); in am65_cpts_of_parse()
1063 cpts->pps_present = false; in am65_cpts_of_parse()
1066 dev_err(cpts->dev, "invalid GENFy index: %u provided\n", prop[1]); in am65_cpts_of_parse()
1067 cpts->pps_present = false; in am65_cpts_of_parse()
1069 if (cpts->pps_present) { in am65_cpts_of_parse()
1070 cpts->pps_hw_ts_idx = prop[0]; in am65_cpts_of_parse()
1071 cpts->pps_genf_idx = prop[1]; in am65_cpts_of_parse()
1080 ptp_clock_unregister(cpts->ptp_clock); in am65_cpts_release()
1082 clk_disable_unprepare(cpts->refclk); in am65_cpts_release()
1094 return ERR_PTR(-ENOMEM); in am65_cpts_create()
1096 cpts->dev = dev; in am65_cpts_create()
1097 cpts->reg = (struct am65_cpts_regs __iomem *)regs; in am65_cpts_create()
1099 cpts->irq = of_irq_get_byname(node, "cpts"); in am65_cpts_create()
1100 if (cpts->irq <= 0) { in am65_cpts_create()
1101 ret = cpts->irq ?: -ENXIO; in am65_cpts_create()
1110 mutex_init(&cpts->ptp_clk_lock); in am65_cpts_create()
1111 INIT_LIST_HEAD(&cpts->events); in am65_cpts_create()
1112 INIT_LIST_HEAD(&cpts->pool); in am65_cpts_create()
1113 spin_lock_init(&cpts->lock); in am65_cpts_create()
1114 skb_queue_head_init(&cpts->txq); in am65_cpts_create()
1117 list_add(&cpts->pool_data[i].list, &cpts->pool); in am65_cpts_create()
1119 cpts->refclk = devm_get_clk_from_child(dev, node, "cpts"); in am65_cpts_create()
1120 if (IS_ERR(cpts->refclk)) { in am65_cpts_create()
1121 ret = PTR_ERR(cpts->refclk); in am65_cpts_create()
1122 dev_err_probe(dev, ret, "Failed to get refclk\n"); in am65_cpts_create()
1126 ret = clk_prepare_enable(cpts->refclk); in am65_cpts_create()
1128 dev_err(dev, "Failed to enable refclk %d\n", ret); in am65_cpts_create()
1132 cpts->refclk_freq = clk_get_rate(cpts->refclk); in am65_cpts_create()
1134 am65_ptp_info.max_adj = cpts->refclk_freq / AM65_CPTS_MIN_PPM; in am65_cpts_create()
1135 cpts->ptp_info = am65_ptp_info; in am65_cpts_create()
1137 if (cpts->ext_ts_inputs) in am65_cpts_create()
1138 cpts->ptp_info.n_ext_ts = cpts->ext_ts_inputs; in am65_cpts_create()
1139 if (cpts->genf_num) in am65_cpts_create()
1140 cpts->ptp_info.n_per_out = cpts->genf_num; in am65_cpts_create()
1141 if (cpts->pps_present) in am65_cpts_create()
1142 cpts->ptp_info.pps = 1; in am65_cpts_create()
1155 cpts->ptp_clock = ptp_clock_register(&cpts->ptp_info, cpts->dev); in am65_cpts_create()
1156 if (IS_ERR_OR_NULL(cpts->ptp_clock)) { in am65_cpts_create()
1158 PTR_ERR(cpts->ptp_clock)); in am65_cpts_create()
1159 ret = cpts->ptp_clock ? PTR_ERR(cpts->ptp_clock) : -ENODEV; in am65_cpts_create()
1162 cpts->phc_index = ptp_clock_index(cpts->ptp_clock); in am65_cpts_create()
1164 ret = devm_request_threaded_irq(dev, cpts->irq, NULL, in am65_cpts_create()
1168 dev_err(cpts->dev, "error attaching irq %d\n", ret); in am65_cpts_create()
1174 cpts->refclk_freq, cpts->ts_add_val, cpts->pps_present); in am65_cpts_create()
1181 clk_disable_unprepare(cpts->refclk); in am65_cpts_create()
1189 cpts->sr_control = am65_cpts_read32(cpts, control); in am65_cpts_suspend()
1190 cpts->sr_int_enable = am65_cpts_read32(cpts, int_enable); in am65_cpts_suspend()
1191 cpts->sr_rftclk_sel = am65_cpts_read32(cpts, rftclk_sel); in am65_cpts_suspend()
1192 cpts->sr_ts_ppm_hi = am65_cpts_read32(cpts, ts_ppm_hi); in am65_cpts_suspend()
1193 cpts->sr_ts_ppm_low = am65_cpts_read32(cpts, ts_ppm_low); in am65_cpts_suspend()
1194 cpts->sr_cpts_ns = am65_cpts_gettime(cpts, NULL); in am65_cpts_suspend()
1195 cpts->sr_ktime_ns = ktime_to_ns(ktime_get_real()); in am65_cpts_suspend()
1197 clk_disable(cpts->refclk); in am65_cpts_suspend()
1200 memcpy_fromio(&cpts->sr_genf, &cpts->reg->genf, sizeof(cpts->sr_genf)); in am65_cpts_suspend()
1203 memcpy_fromio(&cpts->sr_estf, &cpts->reg->estf, sizeof(cpts->sr_estf)); in am65_cpts_suspend()
1213 clk_enable(cpts->refclk); in am65_cpts_resume()
1214 am65_cpts_write32(cpts, cpts->sr_rftclk_sel, rftclk_sel); in am65_cpts_resume()
1216 am65_cpts_write32(cpts, cpts->sr_control, control); in am65_cpts_resume()
1217 am65_cpts_write32(cpts, cpts->sr_int_enable, int_enable); in am65_cpts_resume()
1221 ktime_ns -= cpts->sr_ktime_ns; in am65_cpts_resume()
1222 am65_cpts_settime(cpts, cpts->sr_cpts_ns + ktime_ns); in am65_cpts_resume()
1225 am65_cpts_write32(cpts, cpts->sr_ts_ppm_hi, ts_ppm_hi); in am65_cpts_resume()
1226 am65_cpts_write32(cpts, cpts->sr_ts_ppm_low, ts_ppm_low); in am65_cpts_resume()
1231 am65_cpts_write32(cpts, cpts->sr_genf[i].comp_hi, genf[i].comp_hi); in am65_cpts_resume()
1232 am65_cpts_write32(cpts, cpts->sr_genf[i].comp_lo, genf[i].comp_lo); in am65_cpts_resume()
1233 am65_cpts_write32(cpts, cpts->sr_genf[i].length, genf[i].length); in am65_cpts_resume()
1234 am65_cpts_write32(cpts, cpts->sr_genf[i].control, genf[i].control); in am65_cpts_resume()
1235 am65_cpts_write32(cpts, cpts->sr_genf[i].ppm_hi, genf[i].ppm_hi); in am65_cpts_resume()
1236 am65_cpts_write32(cpts, cpts->sr_genf[i].ppm_low, genf[i].ppm_low); in am65_cpts_resume()
1242 am65_cpts_write32(cpts, cpts->sr_estf[i].comp_hi, estf[i].comp_hi); in am65_cpts_resume()
1243 am65_cpts_write32(cpts, cpts->sr_estf[i].comp_lo, estf[i].comp_lo); in am65_cpts_resume()
1244 am65_cpts_write32(cpts, cpts->sr_estf[i].length, estf[i].length); in am65_cpts_resume()
1245 am65_cpts_write32(cpts, cpts->sr_estf[i].control, estf[i].control); in am65_cpts_resume()
1246 am65_cpts_write32(cpts, cpts->sr_estf[i].ppm_hi, estf[i].ppm_hi); in am65_cpts_resume()
1247 am65_cpts_write32(cpts, cpts->sr_estf[i].ppm_low, estf[i].ppm_low); in am65_cpts_resume()
1254 struct device_node *node = pdev->dev.of_node; in am65_cpts_probe()
1255 struct device *dev = &pdev->dev; in am65_cpts_probe()
1268 { .compatible = "ti,am65-cpts", },
1269 { .compatible = "ti,j721e-cpts", },
1277 .name = "am65-cpts",