]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
net: macb: Fix SUBNS increment and increase resolution
authorHarini Katakam <harini.katakam@xilinx.com>
Thu, 14 Mar 2019 10:11:31 +0000 (15:41 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 15 Mar 2019 10:23:49 +0000 (11:23 +0100)
The subns increment register has 24 bits as follows:
RegBit[15:0] = Subns[23:8]; RegBit[31:24] = Subns[7:0]

Fix the same in the driver and increase sub ns resolution to the
best capable, 24 bits.

Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/net/ethernet/cadence/macb.h
drivers/net/ethernet/cadence/macb_ptp.c

index 4d175545b09b567189b7d81c827f4fe26f403872..e966ab25a5b92daa486fa86c63e5eb3fddfaa714 100644 (file)
 
 /* Bitfields in TISUBN */
 #define GEM_SUBNSINCR_OFFSET                   0
-#define GEM_SUBNSINCR_SIZE                     16
+#define GEM_SUBNSINCRL_OFFSET                  24
+#define GEM_SUBNSINCRL_SIZE                    8
+#define GEM_SUBNSINCRH_OFFSET                  0
+#define GEM_SUBNSINCRH_SIZE                    16
+#define GEM_SUBNSINCR_SIZE                     24
 
 /* Bitfields in TI */
 #define GEM_NSINCR_OFFSET                      0
index 7534932cb482def48fa4e6dd53ef70e31ff453bc..42af7c702b1e3367141b2d293b259972aa48ed68 100644 (file)
@@ -115,7 +115,10 @@ static int gem_tsu_incr_set(struct macb *bp, struct tsu_incr *incr_spec)
         * to take effect.
         */
        spin_lock_irqsave(&bp->tsu_clk_lock, flags);
-       gem_writel(bp, TISUBN, GEM_BF(SUBNSINCR, incr_spec->sub_ns));
+       /* RegBit[15:0] = Subns[23:8]; RegBit[31:24] = Subns[7:0] */
+       gem_writel(bp, TISUBN, GEM_BF(SUBNSINCRL, incr_spec->sub_ns) |
+                  GEM_BF(SUBNSINCRH, (incr_spec->sub_ns >>
+                         GEM_SUBNSINCRL_SIZE)));
        gem_writel(bp, TI, GEM_BF(NSINCR, incr_spec->ns));
        spin_unlock_irqrestore(&bp->tsu_clk_lock, flags);