summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-06-29 14:09:18 -0400
committerDavid S. Miller <davem@davemloft.net>2019-06-29 14:09:18 -0400
commitc09fedd6ad3f55fd298d1acfae6fb14d77a3a4d8 (patch)
treeab279b411a1b23c098c558af7b2231247251eb52
parent79293f49677e2e703ef0d0efc9919319adacb3fb (diff)
parent7ad342bc58cc5197cd2f12a3c30b3949528c6d83 (diff)
Merge branch 'Sub-ns-increment-fixes-in-Macb-PTP'
Harini Katakam says: ==================== Sub ns increment fixes in Macb PTP The subns increment register fields are not captured correctly in the driver. Fix the same and also increase the subns incr resolution. Sub ns resolution was increased to 24 bits in r1p06f2 version. To my knowledge, this PTP driver, with its current BD time stamp implementation, is only useful to that version or above. So, I have increased the resolution unconditionally. Please let me know if there is any IP versions incompatible with this - there is no register to obtain this information from. Changes from RFC: None ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/cadence/macb.h9
-rw-r--r--drivers/net/ethernet/cadence/macb_ptp.c7
2 files changed, 13 insertions, 3 deletions
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 6ff123da6a14..98735584570d 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -496,7 +496,11 @@
496 496
497/* Bitfields in TISUBN */ 497/* Bitfields in TISUBN */
498#define GEM_SUBNSINCR_OFFSET 0 498#define GEM_SUBNSINCR_OFFSET 0
499#define GEM_SUBNSINCR_SIZE 16 499#define GEM_SUBNSINCRL_OFFSET 24
500#define GEM_SUBNSINCRL_SIZE 8
501#define GEM_SUBNSINCRH_OFFSET 0
502#define GEM_SUBNSINCRH_SIZE 16
503#define GEM_SUBNSINCR_SIZE 24
500 504
501/* Bitfields in TI */ 505/* Bitfields in TI */
502#define GEM_NSINCR_OFFSET 0 506#define GEM_NSINCR_OFFSET 0
@@ -834,6 +838,9 @@ struct gem_tx_ts {
834/* limit RX checksum offload to TCP and UDP packets */ 838/* limit RX checksum offload to TCP and UDP packets */
835#define GEM_RX_CSUM_CHECKED_MASK 2 839#define GEM_RX_CSUM_CHECKED_MASK 2
836 840
841/* Scaled PPM fraction */
842#define PPM_FRACTION 16
843
837/* struct macb_tx_skb - data about an skb which is being transmitted 844/* struct macb_tx_skb - data about an skb which is being transmitted
838 * @skb: skb currently being transmitted, only set for the last buffer 845 * @skb: skb currently being transmitted, only set for the last buffer
839 * of the frame 846 * of the frame
diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
index 0a8aca8d3634..43a3f0dbf857 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -104,7 +104,10 @@ static int gem_tsu_incr_set(struct macb *bp, struct tsu_incr *incr_spec)
104 * to take effect. 104 * to take effect.
105 */ 105 */
106 spin_lock_irqsave(&bp->tsu_clk_lock, flags); 106 spin_lock_irqsave(&bp->tsu_clk_lock, flags);
107 gem_writel(bp, TISUBN, GEM_BF(SUBNSINCR, incr_spec->sub_ns)); 107 /* RegBit[15:0] = Subns[23:8]; RegBit[31:24] = Subns[7:0] */
108 gem_writel(bp, TISUBN, GEM_BF(SUBNSINCRL, incr_spec->sub_ns) |
109 GEM_BF(SUBNSINCRH, (incr_spec->sub_ns >>
110 GEM_SUBNSINCRL_SIZE)));
108 gem_writel(bp, TI, GEM_BF(NSINCR, incr_spec->ns)); 111 gem_writel(bp, TI, GEM_BF(NSINCR, incr_spec->ns));
109 spin_unlock_irqrestore(&bp->tsu_clk_lock, flags); 112 spin_unlock_irqrestore(&bp->tsu_clk_lock, flags);
110 113
@@ -135,7 +138,7 @@ static int gem_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
135 * (temp / USEC_PER_SEC) + 0.5 138 * (temp / USEC_PER_SEC) + 0.5
136 */ 139 */
137 adj += (USEC_PER_SEC >> 1); 140 adj += (USEC_PER_SEC >> 1);
138 adj >>= GEM_SUBNSINCR_SIZE; /* remove fractions */ 141 adj >>= PPM_FRACTION; /* remove fractions */
139 adj = div_u64(adj, USEC_PER_SEC); 142 adj = div_u64(adj, USEC_PER_SEC);
140 adj = neg_adj ? (word - adj) : (word + adj); 143 adj = neg_adj ? (word - adj) : (word + adj);
141 144