• Home
  • Raw
  • Download

Lines Matching refs:hellcreek

17 u16 hellcreek_ptp_read(struct hellcreek *hellcreek, unsigned int offset)  in hellcreek_ptp_read()  argument
19 return readw(hellcreek->ptp_base + offset); in hellcreek_ptp_read()
22 void hellcreek_ptp_write(struct hellcreek *hellcreek, u16 data, in hellcreek_ptp_write() argument
25 writew(data, hellcreek->ptp_base + offset); in hellcreek_ptp_write()
29 static u64 hellcreek_ptp_clock_read(struct hellcreek *hellcreek) in hellcreek_ptp_clock_read() argument
34 hellcreek_ptp_write(hellcreek, PR_COMMAND_C_SS, PR_COMMAND_C); in hellcreek_ptp_clock_read()
43 nsh = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C); in hellcreek_ptp_clock_read()
44 nsh = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C); in hellcreek_ptp_clock_read()
45 nsh = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C); in hellcreek_ptp_clock_read()
46 nsh = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C); in hellcreek_ptp_clock_read()
47 nsl = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C); in hellcreek_ptp_clock_read()
52 static u64 __hellcreek_ptp_gettime(struct hellcreek *hellcreek) in __hellcreek_ptp_gettime() argument
56 ns = hellcreek_ptp_clock_read(hellcreek); in __hellcreek_ptp_gettime()
57 if (ns < hellcreek->last_ts) in __hellcreek_ptp_gettime()
58 hellcreek->seconds++; in __hellcreek_ptp_gettime()
59 hellcreek->last_ts = ns; in __hellcreek_ptp_gettime()
60 ns += hellcreek->seconds * NSEC_PER_SEC; in __hellcreek_ptp_gettime()
70 u64 hellcreek_ptp_gettime_seconds(struct hellcreek *hellcreek, u64 ns) in hellcreek_ptp_gettime_seconds() argument
74 __hellcreek_ptp_gettime(hellcreek); in hellcreek_ptp_gettime_seconds()
75 if (hellcreek->last_ts > ns) in hellcreek_ptp_gettime_seconds()
76 s = hellcreek->seconds * NSEC_PER_SEC; in hellcreek_ptp_gettime_seconds()
78 s = (hellcreek->seconds - 1) * NSEC_PER_SEC; in hellcreek_ptp_gettime_seconds()
86 struct hellcreek *hellcreek = ptp_to_hellcreek(ptp); in hellcreek_ptp_gettime() local
89 mutex_lock(&hellcreek->ptp_lock); in hellcreek_ptp_gettime()
90 ns = __hellcreek_ptp_gettime(hellcreek); in hellcreek_ptp_gettime()
91 mutex_unlock(&hellcreek->ptp_lock); in hellcreek_ptp_gettime()
101 struct hellcreek *hellcreek = ptp_to_hellcreek(ptp); in hellcreek_ptp_settime() local
108 mutex_lock(&hellcreek->ptp_lock); in hellcreek_ptp_settime()
111 hellcreek->seconds = ts->tv_sec; in hellcreek_ptp_settime()
112 hellcreek->last_ts = ts->tv_nsec; in hellcreek_ptp_settime()
115 hellcreek_ptp_write(hellcreek, 0x00, PR_CLOCK_WRITE_C); in hellcreek_ptp_settime()
116 hellcreek_ptp_write(hellcreek, 0x00, PR_CLOCK_WRITE_C); in hellcreek_ptp_settime()
117 hellcreek_ptp_write(hellcreek, secl, PR_CLOCK_WRITE_C); in hellcreek_ptp_settime()
118 hellcreek_ptp_write(hellcreek, nsh, PR_CLOCK_WRITE_C); in hellcreek_ptp_settime()
119 hellcreek_ptp_write(hellcreek, nsl, PR_CLOCK_WRITE_C); in hellcreek_ptp_settime()
121 mutex_unlock(&hellcreek->ptp_lock); in hellcreek_ptp_settime()
128 struct hellcreek *hellcreek = ptp_to_hellcreek(ptp); in hellcreek_ptp_adjfine() local
159 mutex_lock(&hellcreek->ptp_lock); in hellcreek_ptp_adjfine()
162 hellcreek_ptp_write(hellcreek, negative, PR_CLOCK_DRIFT_C); in hellcreek_ptp_adjfine()
163 hellcreek_ptp_write(hellcreek, 0x00, PR_CLOCK_DRIFT_C); in hellcreek_ptp_adjfine()
164 hellcreek_ptp_write(hellcreek, 0x00, PR_CLOCK_DRIFT_C); in hellcreek_ptp_adjfine()
165 hellcreek_ptp_write(hellcreek, addendh, PR_CLOCK_DRIFT_C); in hellcreek_ptp_adjfine()
166 hellcreek_ptp_write(hellcreek, addendl, PR_CLOCK_DRIFT_C); in hellcreek_ptp_adjfine()
168 mutex_unlock(&hellcreek->ptp_lock); in hellcreek_ptp_adjfine()
175 struct hellcreek *hellcreek = ptp_to_hellcreek(ptp); in hellcreek_ptp_adjtime() local
206 mutex_lock(&hellcreek->ptp_lock); in hellcreek_ptp_adjtime()
209 hellcreek_ptp_write(hellcreek, negative, PR_CLOCK_OFFSET_C); in hellcreek_ptp_adjtime()
210 hellcreek_ptp_write(hellcreek, MAX_NS_PER_STEP, PR_CLOCK_OFFSET_C); in hellcreek_ptp_adjtime()
211 hellcreek_ptp_write(hellcreek, MIN_CLK_CYCLES_BETWEEN_STEPS, in hellcreek_ptp_adjtime()
213 hellcreek_ptp_write(hellcreek, countl, PR_CLOCK_OFFSET_C); in hellcreek_ptp_adjtime()
214 hellcreek_ptp_write(hellcreek, counth, PR_CLOCK_OFFSET_C); in hellcreek_ptp_adjtime()
216 mutex_unlock(&hellcreek->ptp_lock); in hellcreek_ptp_adjtime()
230 struct hellcreek *hellcreek; in hellcreek_ptp_overflow_check() local
232 hellcreek = dw_overflow_to_hellcreek(dw); in hellcreek_ptp_overflow_check()
234 mutex_lock(&hellcreek->ptp_lock); in hellcreek_ptp_overflow_check()
235 __hellcreek_ptp_gettime(hellcreek); in hellcreek_ptp_overflow_check()
236 mutex_unlock(&hellcreek->ptp_lock); in hellcreek_ptp_overflow_check()
238 schedule_delayed_work(&hellcreek->overflow_work, in hellcreek_ptp_overflow_check()
242 static enum led_brightness hellcreek_get_brightness(struct hellcreek *hellcreek, in hellcreek_get_brightness() argument
245 return (hellcreek->status_out & led) ? 1 : 0; in hellcreek_get_brightness()
248 static void hellcreek_set_brightness(struct hellcreek *hellcreek, int led, in hellcreek_set_brightness() argument
251 mutex_lock(&hellcreek->ptp_lock); in hellcreek_set_brightness()
254 hellcreek->status_out |= led; in hellcreek_set_brightness()
256 hellcreek->status_out &= ~led; in hellcreek_set_brightness()
258 hellcreek_ptp_write(hellcreek, hellcreek->status_out, STATUS_OUT); in hellcreek_set_brightness()
260 mutex_unlock(&hellcreek->ptp_lock); in hellcreek_set_brightness()
266 struct hellcreek *hellcreek = led_to_hellcreek(ldev, led_sync_good); in hellcreek_led_sync_good_set() local
268 hellcreek_set_brightness(hellcreek, STATUS_OUT_SYNC_GOOD, b); in hellcreek_led_sync_good_set()
273 struct hellcreek *hellcreek = led_to_hellcreek(ldev, led_sync_good); in hellcreek_led_sync_good_get() local
275 return hellcreek_get_brightness(hellcreek, STATUS_OUT_SYNC_GOOD); in hellcreek_led_sync_good_get()
281 struct hellcreek *hellcreek = led_to_hellcreek(ldev, led_is_gm); in hellcreek_led_is_gm_set() local
283 hellcreek_set_brightness(hellcreek, STATUS_OUT_IS_GM, b); in hellcreek_led_is_gm_set()
288 struct hellcreek *hellcreek = led_to_hellcreek(ldev, led_is_gm); in hellcreek_led_is_gm_get() local
290 return hellcreek_get_brightness(hellcreek, STATUS_OUT_IS_GM); in hellcreek_led_is_gm_get()
297 static int hellcreek_led_setup(struct hellcreek *hellcreek) in hellcreek_led_setup() argument
303 of_node_get(hellcreek->dev->of_node); in hellcreek_led_setup()
304 leds = of_find_node_by_name(hellcreek->dev->of_node, "leds"); in hellcreek_led_setup()
306 dev_err(hellcreek->dev, "No LEDs specified in device tree!\n"); in hellcreek_led_setup()
310 hellcreek->status_out = 0; in hellcreek_led_setup()
314 dev_err(hellcreek->dev, "First LED not specified!\n"); in hellcreek_led_setup()
319 hellcreek->led_sync_good.name = ret ? "sync_good" : label; in hellcreek_led_setup()
324 hellcreek->led_sync_good.brightness = 1; in hellcreek_led_setup()
326 hellcreek->led_sync_good.brightness = 0; in hellcreek_led_setup()
328 hellcreek->led_sync_good.brightness = in hellcreek_led_setup()
329 hellcreek_get_brightness(hellcreek, in hellcreek_led_setup()
333 hellcreek->led_sync_good.max_brightness = 1; in hellcreek_led_setup()
334 hellcreek->led_sync_good.brightness_set = hellcreek_led_sync_good_set; in hellcreek_led_setup()
335 hellcreek->led_sync_good.brightness_get = hellcreek_led_sync_good_get; in hellcreek_led_setup()
339 dev_err(hellcreek->dev, "Second LED not specified!\n"); in hellcreek_led_setup()
345 hellcreek->led_is_gm.name = ret ? "is_gm" : label; in hellcreek_led_setup()
350 hellcreek->led_is_gm.brightness = 1; in hellcreek_led_setup()
352 hellcreek->led_is_gm.brightness = 0; in hellcreek_led_setup()
354 hellcreek->led_is_gm.brightness = in hellcreek_led_setup()
355 hellcreek_get_brightness(hellcreek, in hellcreek_led_setup()
359 hellcreek->led_is_gm.max_brightness = 1; in hellcreek_led_setup()
360 hellcreek->led_is_gm.brightness_set = hellcreek_led_is_gm_set; in hellcreek_led_setup()
361 hellcreek->led_is_gm.brightness_get = hellcreek_led_is_gm_get; in hellcreek_led_setup()
364 if (hellcreek->led_sync_good.brightness == 1) in hellcreek_led_setup()
365 hellcreek_set_brightness(hellcreek, STATUS_OUT_SYNC_GOOD, 1); in hellcreek_led_setup()
366 if (hellcreek->led_is_gm.brightness == 1) in hellcreek_led_setup()
367 hellcreek_set_brightness(hellcreek, STATUS_OUT_IS_GM, 1); in hellcreek_led_setup()
370 led_classdev_register(hellcreek->dev, &hellcreek->led_sync_good); in hellcreek_led_setup()
371 led_classdev_register(hellcreek->dev, &hellcreek->led_is_gm); in hellcreek_led_setup()
381 int hellcreek_ptp_setup(struct hellcreek *hellcreek) in hellcreek_ptp_setup() argument
387 INIT_DELAYED_WORK(&hellcreek->overflow_work, in hellcreek_ptp_setup()
391 hellcreek->ptp_clock_info.owner = THIS_MODULE; in hellcreek_ptp_setup()
392 snprintf(hellcreek->ptp_clock_info.name, in hellcreek_ptp_setup()
393 sizeof(hellcreek->ptp_clock_info.name), in hellcreek_ptp_setup()
394 dev_name(hellcreek->dev)); in hellcreek_ptp_setup()
400 hellcreek->ptp_clock_info.max_adj = 62500000; in hellcreek_ptp_setup()
401 hellcreek->ptp_clock_info.n_alarm = 0; in hellcreek_ptp_setup()
402 hellcreek->ptp_clock_info.n_pins = 0; in hellcreek_ptp_setup()
403 hellcreek->ptp_clock_info.n_ext_ts = 0; in hellcreek_ptp_setup()
404 hellcreek->ptp_clock_info.n_per_out = 0; in hellcreek_ptp_setup()
405 hellcreek->ptp_clock_info.pps = 0; in hellcreek_ptp_setup()
406 hellcreek->ptp_clock_info.adjfine = hellcreek_ptp_adjfine; in hellcreek_ptp_setup()
407 hellcreek->ptp_clock_info.adjtime = hellcreek_ptp_adjtime; in hellcreek_ptp_setup()
408 hellcreek->ptp_clock_info.gettime64 = hellcreek_ptp_gettime; in hellcreek_ptp_setup()
409 hellcreek->ptp_clock_info.settime64 = hellcreek_ptp_settime; in hellcreek_ptp_setup()
410 hellcreek->ptp_clock_info.enable = hellcreek_ptp_enable; in hellcreek_ptp_setup()
411 hellcreek->ptp_clock_info.do_aux_work = hellcreek_hwtstamp_work; in hellcreek_ptp_setup()
413 hellcreek->ptp_clock = ptp_clock_register(&hellcreek->ptp_clock_info, in hellcreek_ptp_setup()
414 hellcreek->dev); in hellcreek_ptp_setup()
415 if (IS_ERR(hellcreek->ptp_clock)) in hellcreek_ptp_setup()
416 return PTR_ERR(hellcreek->ptp_clock); in hellcreek_ptp_setup()
421 status = hellcreek_ptp_read(hellcreek, PR_CLOCK_STATUS_C); in hellcreek_ptp_setup()
423 hellcreek_ptp_write(hellcreek, in hellcreek_ptp_setup()
428 hellcreek_ptp_write(hellcreek, status | PR_CLOCK_STATUS_C_ENA_DRIFT, in hellcreek_ptp_setup()
432 ret = hellcreek_led_setup(hellcreek); in hellcreek_ptp_setup()
434 if (hellcreek->ptp_clock) in hellcreek_ptp_setup()
435 ptp_clock_unregister(hellcreek->ptp_clock); in hellcreek_ptp_setup()
439 schedule_delayed_work(&hellcreek->overflow_work, in hellcreek_ptp_setup()
445 void hellcreek_ptp_free(struct hellcreek *hellcreek) in hellcreek_ptp_free() argument
447 led_classdev_unregister(&hellcreek->led_is_gm); in hellcreek_ptp_free()
448 led_classdev_unregister(&hellcreek->led_sync_good); in hellcreek_ptp_free()
449 cancel_delayed_work_sync(&hellcreek->overflow_work); in hellcreek_ptp_free()
450 if (hellcreek->ptp_clock) in hellcreek_ptp_free()
451 ptp_clock_unregister(hellcreek->ptp_clock); in hellcreek_ptp_free()
452 hellcreek->ptp_clock = NULL; in hellcreek_ptp_free()