Commit be3378cc authored by Alessandro Rubini's avatar Alessandro Rubini

kernel modules: the clock is 62.5MHz, parametrize tick

parent dd1cfdc2
......@@ -62,6 +62,9 @@ static struct platform_device wrn_device = {
*/
int __init wrn_init(void)
{
/* The clock period must be a multiple of 1ns, so bug out otherwise */
BUILD_BUG_ON(REFCLK_FREQ * NSEC_PER_TICK != NSEC_PER_SEC);
/* A few fields must be initialized at run time */
spin_lock_init(&wrn_dev.lock);
......
......@@ -339,7 +339,7 @@ static void __wrn_rx_descriptor(struct wrn_dev *wrn, int desc)
/* the bit says the rising edge cnter is 1tick ahead */
if(cntr_diff == 1 || cntr_diff == (-0xf))
ts.tv_sec |= 0x80000000;
ts.tv_nsec = ts_r * 8; /* scale to nanoseconds */
ts.tv_nsec = ts_r * NSEC_PER_TICK;
pr_debug("Timestamp: %li:%li, ahead = %d\n",
ts.tv_sec & 0x7fffffff,
......
......@@ -11,10 +11,9 @@
#ifndef __WR_NIC_HARDWARE_H__
#define __WR_NIC_HARDWARE_H__
/* Our host CPU is this one, no way out of it */
//#include <mach/at91sam9263.h>
#define REFCLK_FREQ 125000000
/* This is the clock used in internal counters. */
#define REFCLK_FREQ (125000000 / 2)
#define NSEC_PER_TICK (NSEC_PER_SEC / REFCLK_FREQ)
/* The interrupt is one of those managed by our WRVIC device */
#define WRN_IRQ_BASE 192
......
......@@ -43,7 +43,7 @@ void wrn_tstamp_find_skb(struct wrn_dev *wrn, int desc)
utc--;
ts.tv_sec = (s32)utc & 0x7fffffff;
ts.tv_nsec = wrn->ts_buf[i].ts * 8; /* scale to nsecs */
ts.tv_nsec = wrn->ts_buf[i].ts * NSEC_PER_TICK;
hwts->hwtstamp = timespec_to_ktime(ts);
skb_tstamp_tx(skb, hwts);
dev_kfree_skb_irq(skb);
......@@ -82,7 +82,7 @@ static int record_tstamp(struct wrn_dev *wrn, u32 tsval, u32 idreg)
utc--;
ts.tv_sec = (s32)utc & 0x7fffffff;
ts.tv_nsec = (tsval & 0xfffffff) * 8; /* scale to nanoseconds */
ts.tv_nsec = (tsval & 0xfffffff) * NSEC_PER_TICK;
hwts->hwtstamp = timespec_to_ktime(ts);
skb_tstamp_tx(skb, hwts);
dev_kfree_skb_irq(skb);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment