diff options
Diffstat (limited to 'drivers/net/wireless/ti/wl18xx/event.c')
-rw-r--r-- | drivers/net/wireless/ti/wl18xx/event.c | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/drivers/net/wireless/ti/wl18xx/event.c b/drivers/net/wireless/ti/wl18xx/event.c index 5976b7f7d75a..bc2c958b964d 100644 --- a/drivers/net/wireless/ti/wl18xx/event.c +++ b/drivers/net/wireless/ti/wl18xx/event.c | |||
@@ -20,8 +20,6 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <net/genetlink.h> | 22 | #include <net/genetlink.h> |
23 | #include <linux/hrtimer.h> | ||
24 | #include <linux/ktime.h> | ||
25 | #include "event.h" | 23 | #include "event.h" |
26 | #include "scan.h" | 24 | #include "scan.h" |
27 | #include "conf.h" | 25 | #include "conf.h" |
@@ -119,40 +117,14 @@ static void wlcore_event_time_sync(struct wl1271 *wl, | |||
119 | u16 tsf_high_msb, u16 tsf_high_lsb, | 117 | u16 tsf_high_msb, u16 tsf_high_lsb, |
120 | u16 tsf_low_msb, u16 tsf_low_lsb) | 118 | u16 tsf_low_msb, u16 tsf_low_lsb) |
121 | { | 119 | { |
122 | ktime_t ktime; | 120 | u32 clock_low; |
123 | u32 clock_low; | 121 | u32 clock_high; |
124 | u32 clock_high; | 122 | |
125 | u32 interval_usc; | 123 | clock_high = (tsf_high_msb << 16) | tsf_high_lsb; |
126 | u32 mod_usc; | 124 | clock_low = (tsf_low_msb << 16) | tsf_low_lsb; |
127 | u32 next_tick_usc; | 125 | |
128 | 126 | wl1271_info("TIME_SYNC_EVENT_ID: clock_high %u, clock low %u", | |
129 | /* convert the MSB+LSB to a u32 TSF value */ | 127 | clock_high, clock_low); |
130 | clock_high = (tsf_high_msb << 16) | tsf_high_lsb; | ||
131 | clock_low = (tsf_low_msb << 16) | tsf_low_lsb; | ||
132 | |||
133 | wl1271_info("TIME_SYNC_EVENT_ID+: clock_high %u, clock low %u", | ||
134 | clock_high, clock_low); | ||
135 | |||
136 | /* Calculate the next tick */ | ||
137 | interval_usc = wl->time_sync.interval_ms * USEC_PER_MSEC; | ||
138 | mod_usc = clock_low % interval_usc; | ||
139 | next_tick_usc = interval_usc - mod_usc; | ||
140 | |||
141 | /* skip the current interval if it's too close in time */ | ||
142 | if (next_tick_usc < 5000) | ||
143 | next_tick_usc = next_tick_usc + interval_usc; | ||
144 | |||
145 | /* schedule hr timer 200ns before the desired time */ | ||
146 | ktime = ktime_add_ns(wl->time_sync.gpio_ktime, | ||
147 | NSEC_PER_USEC * (next_tick_usc - 200)); | ||
148 | |||
149 | /* save the actual target time for the next wake-up */ | ||
150 | wl->time_sync.target_ktime = | ||
151 | ktime_add_ns(wl->time_sync.gpio_ktime, | ||
152 | NSEC_PER_USEC * (next_tick_usc)); | ||
153 | |||
154 | /* set the timer */ | ||
155 | hrtimer_start(&wl->time_sync.timer, ktime, HRTIMER_MODE_ABS); | ||
156 | } | 128 | } |
157 | 129 | ||
158 | int wl18xx_process_mailbox_events(struct wl1271 *wl) | 130 | int wl18xx_process_mailbox_events(struct wl1271 *wl) |