Hi Richard,

I am writing the incval to the register in adjfreq after the calculation.I
had written that in the comments and actual code is below.
out_be32((timer->baseaddr + XTIMER1588_RTC_INCREMENT), incval);


In adjtime: delta is passed to  ns_to_timespec
then = ns_to_timespec(delta)
offset = then; /* then is copied to offset */
 xlnx_rtc_offset_write(timer, (const struct timespec *)&offset); /* This
offset is written to the register */


Best Regards,
Sujatha


On Thu, Feb 18, 2016 at 2:59 PM, Richard Cochran <richardcoch...@gmail.com>
wrote:

> Wow, your code is totally broken...
>
> On Thu, Feb 18, 2016 at 12:04:22PM +0530, Sujatha Guguloth wrote:
> > static int xlnx_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
> > {
> >         struct xlnx_ptp_timer *timer = container_of(ptp, struct
> > xlnx_ptp_timer,
> >                                               ptp_clock_info);
> >
> >         int neg_adj = 0;
> >         u64 freq = 0;
> >         u32 diff = 0;
> >         u32 incval = 0;
> >
> >         /* External clock source Frequency is 200MHz    which is driving
> > the timer  */
> >         /* adjust the RTC Increment Control register by (1/200MHZ =
> 5ns)  */
> >         /* resolution of the increment register is 1/1048576
>   */
> >         /* hence 5 * 1048576 = 0x500000 - value to be written to the
> > register */
> >         incval = 0x500000;
> >
> >         if (ppb < 0) {
> >           neg_adj = 1;
> >           ppb = -ppb;
> >         }
> >
> >         freq = incval;
> >         freq *= ppb;
> >         diff = div_u64(freq, 1000000000ULL);
> >
> >         incval = neg_adj ? (incval - diff) : (incval + diff);
> >
> >         /* Write the adjusted value to the *RTC Increment Value Control
> > Register* */
> >         /* Writing the adjustment value to this register intern adjusts
> the
> > nanoseconds register value by the hw */
>
> You calculate 'incval' and then do nothing with it.
>
> >         return 0;
> > }
> >
> >
> > static int xlnx_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
> > {
> >         unsigned long flags = 0;
> >         struct xlnx_ptp_timer *timer = container_of(ptp, struct
> > xlnx_ptp_timer,
> >                                               ptp_clock_info);
> >         struct timespec offset, then = ns_to_timespec(delta);
> >
> >         spin_lock_irqsave(&timer->reg_lock, flags);
> >
> >         /* Read the seconds and nano seconds from the RTC Seconds and RTC
> > Nano Seconds Registers */
> >         xlnx_rtc_offset_read(timer, &offset);
> >
> >         /* set the current offset values */
> >         offset = then;
>
> You are supposed to add the delta.
>
> >         /* Write the seconds and nano seconds to the *RTC Seconds* and
> *RTC
> > Nano Seconds* Registers */
> >         xlnx_rtc_offset_write(timer, (const struct timespec *)&offset);
> >
> >         spin_unlock_irqrestore(&timer->reg_lock, flags);
> >         return 0;
> > }
>
> Good luck,
> Richard
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Linuxptp-users mailing list
Linuxptp-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-users

Reply via email to