time.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. /*
  2. * Copyright 2001 MontaVista Software Inc.
  3. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  4. * Copyright (c) 2003, 2004 Maciej W. Rozycki
  5. *
  6. * Common time service routines for MIPS machines. See
  7. * Documentation/mips/time.README.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. #include <linux/types.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/sched.h>
  18. #include <linux/param.h>
  19. #include <linux/time.h>
  20. #include <linux/timex.h>
  21. #include <linux/smp.h>
  22. #include <linux/kernel_stat.h>
  23. #include <linux/spinlock.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/module.h>
  26. #include <asm/bootinfo.h>
  27. #include <asm/cache.h>
  28. #include <asm/compiler.h>
  29. #include <asm/cpu.h>
  30. #include <asm/cpu-features.h>
  31. #include <asm/div64.h>
  32. #include <asm/sections.h>
  33. #include <asm/time.h>
  34. /*
  35. * The integer part of the number of usecs per jiffy is taken from tick,
  36. * but the fractional part is not recorded, so we calculate it using the
  37. * initial value of HZ. This aids systems where tick isn't really an
  38. * integer (e.g. for HZ = 128).
  39. */
  40. #define USECS_PER_JIFFY TICK_SIZE
  41. #define USECS_PER_JIFFY_FRAC ((unsigned long)(u32)((1000000ULL << 32) / HZ))
  42. #define TICK_SIZE (tick_nsec / 1000)
  43. /*
  44. * forward reference
  45. */
  46. DEFINE_SPINLOCK(rtc_lock);
  47. /*
  48. * By default we provide the null RTC ops
  49. */
  50. static unsigned long null_rtc_get_time(void)
  51. {
  52. return mktime(2000, 1, 1, 0, 0, 0);
  53. }
  54. static int null_rtc_set_time(unsigned long sec)
  55. {
  56. return 0;
  57. }
  58. unsigned long (*rtc_mips_get_time)(void) = null_rtc_get_time;
  59. int (*rtc_mips_set_time)(unsigned long) = null_rtc_set_time;
  60. int (*rtc_mips_set_mmss)(unsigned long);
  61. /* usecs per counter cycle, shifted to left by 32 bits */
  62. static unsigned int sll32_usecs_per_cycle;
  63. /* how many counter cycles in a jiffy */
  64. static unsigned long cycles_per_jiffy __read_mostly;
  65. /* Cycle counter value at the previous timer interrupt.. */
  66. static unsigned int timerhi, timerlo;
  67. /* expirelo is the count value for next CPU timer interrupt */
  68. static unsigned int expirelo;
  69. /*
  70. * Null timer ack for systems not needing one (e.g. i8254).
  71. */
  72. static void null_timer_ack(void) { /* nothing */ }
  73. /*
  74. * Null high precision timer functions for systems lacking one.
  75. */
  76. static unsigned int null_hpt_read(void)
  77. {
  78. return 0;
  79. }
  80. static void null_hpt_init(unsigned int count)
  81. {
  82. /* nothing */
  83. }
  84. /*
  85. * Timer ack for an R4k-compatible timer of a known frequency.
  86. */
  87. static void c0_timer_ack(void)
  88. {
  89. unsigned int count;
  90. #ifndef CONFIG_SOC_PNX8550 /* pnx8550 resets to zero */
  91. /* Ack this timer interrupt and set the next one. */
  92. expirelo += cycles_per_jiffy;
  93. #endif
  94. write_c0_compare(expirelo);
  95. /* Check to see if we have missed any timer interrupts. */
  96. while (((count = read_c0_count()) - expirelo) < 0x7fffffff) {
  97. /* missed_timer_count++; */
  98. expirelo = count + cycles_per_jiffy;
  99. write_c0_compare(expirelo);
  100. }
  101. }
  102. /*
  103. * High precision timer functions for a R4k-compatible timer.
  104. */
  105. static unsigned int c0_hpt_read(void)
  106. {
  107. return read_c0_count();
  108. }
  109. /* For use solely as a high precision timer. */
  110. static void c0_hpt_init(unsigned int count)
  111. {
  112. write_c0_count(read_c0_count() - count);
  113. }
  114. /* For use both as a high precision timer and an interrupt source. */
  115. static void c0_hpt_timer_init(unsigned int count)
  116. {
  117. count = read_c0_count() - count;
  118. expirelo = (count / cycles_per_jiffy + 1) * cycles_per_jiffy;
  119. write_c0_count(expirelo - cycles_per_jiffy);
  120. write_c0_compare(expirelo);
  121. write_c0_count(count);
  122. }
  123. int (*mips_timer_state)(void);
  124. void (*mips_timer_ack)(void);
  125. unsigned int (*mips_hpt_read)(void);
  126. void (*mips_hpt_init)(unsigned int);
  127. /*
  128. * Gettimeoffset routines. These routines returns the time duration
  129. * since last timer interrupt in usecs.
  130. *
  131. * If the exact CPU counter frequency is known, use fixed_rate_gettimeoffset.
  132. * Otherwise use calibrate_gettimeoffset()
  133. *
  134. * If the CPU does not have the counter register, you can either supply
  135. * your own gettimeoffset() routine, or use null_gettimeoffset(), which
  136. * gives the same resolution as HZ.
  137. */
  138. static unsigned long null_gettimeoffset(void)
  139. {
  140. return 0;
  141. }
  142. /* The function pointer to one of the gettimeoffset funcs. */
  143. unsigned long (*do_gettimeoffset)(void) = null_gettimeoffset;
  144. static unsigned long fixed_rate_gettimeoffset(void)
  145. {
  146. u32 count;
  147. unsigned long res;
  148. /* Get last timer tick in absolute kernel time */
  149. count = mips_hpt_read();
  150. /* .. relative to previous jiffy (32 bits is enough) */
  151. count -= timerlo;
  152. __asm__("multu %1,%2"
  153. : "=h" (res)
  154. : "r" (count), "r" (sll32_usecs_per_cycle)
  155. : "lo", GCC_REG_ACCUM);
  156. /*
  157. * Due to possible jiffies inconsistencies, we need to check
  158. * the result so that we'll get a timer that is monotonic.
  159. */
  160. if (res >= USECS_PER_JIFFY)
  161. res = USECS_PER_JIFFY - 1;
  162. return res;
  163. }
  164. /*
  165. * Cached "1/(clocks per usec) * 2^32" value.
  166. * It has to be recalculated once each jiffy.
  167. */
  168. static unsigned long cached_quotient;
  169. /* Last jiffy when calibrate_divXX_gettimeoffset() was called. */
  170. static unsigned long last_jiffies;
  171. /*
  172. * This is moved from dec/time.c:do_ioasic_gettimeoffset() by Maciej.
  173. */
  174. static unsigned long calibrate_div32_gettimeoffset(void)
  175. {
  176. u32 count;
  177. unsigned long res, tmp;
  178. unsigned long quotient;
  179. tmp = jiffies;
  180. quotient = cached_quotient;
  181. if (last_jiffies != tmp) {
  182. last_jiffies = tmp;
  183. if (last_jiffies != 0) {
  184. unsigned long r0;
  185. do_div64_32(r0, timerhi, timerlo, tmp);
  186. do_div64_32(quotient, USECS_PER_JIFFY,
  187. USECS_PER_JIFFY_FRAC, r0);
  188. cached_quotient = quotient;
  189. }
  190. }
  191. /* Get last timer tick in absolute kernel time */
  192. count = mips_hpt_read();
  193. /* .. relative to previous jiffy (32 bits is enough) */
  194. count -= timerlo;
  195. __asm__("multu %1,%2"
  196. : "=h" (res)
  197. : "r" (count), "r" (quotient)
  198. : "lo", GCC_REG_ACCUM);
  199. /*
  200. * Due to possible jiffies inconsistencies, we need to check
  201. * the result so that we'll get a timer that is monotonic.
  202. */
  203. if (res >= USECS_PER_JIFFY)
  204. res = USECS_PER_JIFFY - 1;
  205. return res;
  206. }
  207. static unsigned long calibrate_div64_gettimeoffset(void)
  208. {
  209. u32 count;
  210. unsigned long res, tmp;
  211. unsigned long quotient;
  212. tmp = jiffies;
  213. quotient = cached_quotient;
  214. if (last_jiffies != tmp) {
  215. last_jiffies = tmp;
  216. if (last_jiffies) {
  217. unsigned long r0;
  218. __asm__(".set push\n\t"
  219. ".set mips3\n\t"
  220. "lwu %0,%3\n\t"
  221. "dsll32 %1,%2,0\n\t"
  222. "or %1,%1,%0\n\t"
  223. "ddivu $0,%1,%4\n\t"
  224. "mflo %1\n\t"
  225. "dsll32 %0,%5,0\n\t"
  226. "or %0,%0,%6\n\t"
  227. "ddivu $0,%0,%1\n\t"
  228. "mflo %0\n\t"
  229. ".set pop"
  230. : "=&r" (quotient), "=&r" (r0)
  231. : "r" (timerhi), "m" (timerlo),
  232. "r" (tmp), "r" (USECS_PER_JIFFY),
  233. "r" (USECS_PER_JIFFY_FRAC)
  234. : "hi", "lo", GCC_REG_ACCUM);
  235. cached_quotient = quotient;
  236. }
  237. }
  238. /* Get last timer tick in absolute kernel time */
  239. count = mips_hpt_read();
  240. /* .. relative to previous jiffy (32 bits is enough) */
  241. count -= timerlo;
  242. __asm__("multu %1,%2"
  243. : "=h" (res)
  244. : "r" (count), "r" (quotient)
  245. : "lo", GCC_REG_ACCUM);
  246. /*
  247. * Due to possible jiffies inconsistencies, we need to check
  248. * the result so that we'll get a timer that is monotonic.
  249. */
  250. if (res >= USECS_PER_JIFFY)
  251. res = USECS_PER_JIFFY - 1;
  252. return res;
  253. }
  254. /* last time when xtime and rtc are sync'ed up */
  255. static long last_rtc_update;
  256. /*
  257. * local_timer_interrupt() does profiling and process accounting
  258. * on a per-CPU basis.
  259. *
  260. * In UP mode, it is invoked from the (global) timer_interrupt.
  261. *
  262. * In SMP mode, it might invoked by per-CPU timer interrupt, or
  263. * a broadcasted inter-processor interrupt which itself is triggered
  264. * by the global timer interrupt.
  265. */
  266. void local_timer_interrupt(int irq, void *dev_id)
  267. {
  268. profile_tick(CPU_PROFILING);
  269. update_process_times(user_mode(get_irq_regs()));
  270. }
  271. /*
  272. * High-level timer interrupt service routines. This function
  273. * is set as irqaction->handler and is invoked through do_IRQ.
  274. */
  275. irqreturn_t timer_interrupt(int irq, void *dev_id)
  276. {
  277. unsigned long j;
  278. unsigned int count;
  279. write_seqlock(&xtime_lock);
  280. count = mips_hpt_read();
  281. mips_timer_ack();
  282. /* Update timerhi/timerlo for intra-jiffy calibration. */
  283. timerhi += count < timerlo; /* Wrap around */
  284. timerlo = count;
  285. /*
  286. * call the generic timer interrupt handling
  287. */
  288. do_timer(1);
  289. /*
  290. * If we have an externally synchronized Linux clock, then update
  291. * CMOS clock accordingly every ~11 minutes. rtc_mips_set_time() has to be
  292. * called as close as possible to 500 ms before the new second starts.
  293. */
  294. if (ntp_synced() &&
  295. xtime.tv_sec > last_rtc_update + 660 &&
  296. (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
  297. (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
  298. if (rtc_mips_set_mmss(xtime.tv_sec) == 0) {
  299. last_rtc_update = xtime.tv_sec;
  300. } else {
  301. /* do it again in 60 s */
  302. last_rtc_update = xtime.tv_sec - 600;
  303. }
  304. }
  305. /*
  306. * If jiffies has overflown in this timer_interrupt, we must
  307. * update the timer[hi]/[lo] to make fast gettimeoffset funcs
  308. * quotient calc still valid. -arca
  309. *
  310. * The first timer interrupt comes late as interrupts are
  311. * enabled long after timers are initialized. Therefore the
  312. * high precision timer is fast, leading to wrong gettimeoffset()
  313. * calculations. We deal with it by setting it based on the
  314. * number of its ticks between the second and the third interrupt.
  315. * That is still somewhat imprecise, but it's a good estimate.
  316. * --macro
  317. */
  318. j = jiffies;
  319. if (j < 4) {
  320. static unsigned int prev_count;
  321. static int hpt_initialized;
  322. switch (j) {
  323. case 0:
  324. timerhi = timerlo = 0;
  325. mips_hpt_init(count);
  326. break;
  327. case 2:
  328. prev_count = count;
  329. break;
  330. case 3:
  331. if (!hpt_initialized) {
  332. unsigned int c3 = 3 * (count - prev_count);
  333. timerhi = 0;
  334. timerlo = c3;
  335. mips_hpt_init(count - c3);
  336. hpt_initialized = 1;
  337. }
  338. break;
  339. default:
  340. break;
  341. }
  342. }
  343. write_sequnlock(&xtime_lock);
  344. /*
  345. * In UP mode, we call local_timer_interrupt() to do profiling
  346. * and process accouting.
  347. *
  348. * In SMP mode, local_timer_interrupt() is invoked by appropriate
  349. * low-level local timer interrupt handler.
  350. */
  351. local_timer_interrupt(irq, dev_id);
  352. return IRQ_HANDLED;
  353. }
  354. int null_perf_irq(void)
  355. {
  356. return 0;
  357. }
  358. int (*perf_irq)(void) = null_perf_irq;
  359. EXPORT_SYMBOL(null_perf_irq);
  360. EXPORT_SYMBOL(perf_irq);
  361. asmlinkage void ll_timer_interrupt(int irq)
  362. {
  363. int r2 = cpu_has_mips_r2;
  364. irq_enter();
  365. kstat_this_cpu.irqs[irq]++;
  366. /*
  367. * Suckage alert:
  368. * Before R2 of the architecture there was no way to see if a
  369. * performance counter interrupt was pending, so we have to run the
  370. * performance counter interrupt handler anyway.
  371. */
  372. if (!r2 || (read_c0_cause() & (1 << 26)))
  373. if (perf_irq())
  374. goto out;
  375. /* we keep interrupt disabled all the time */
  376. if (!r2 || (read_c0_cause() & (1 << 30)))
  377. timer_interrupt(irq, NULL);
  378. out:
  379. irq_exit();
  380. }
  381. asmlinkage void ll_local_timer_interrupt(int irq)
  382. {
  383. irq_enter();
  384. if (smp_processor_id() != 0)
  385. kstat_this_cpu.irqs[irq]++;
  386. /* we keep interrupt disabled all the time */
  387. local_timer_interrupt(irq, NULL);
  388. irq_exit();
  389. }
  390. /*
  391. * time_init() - it does the following things.
  392. *
  393. * 1) board_time_init() -
  394. * a) (optional) set up RTC routines,
  395. * b) (optional) calibrate and set the mips_hpt_frequency
  396. * (only needed if you intended to use fixed_rate_gettimeoffset
  397. * or use cpu counter as timer interrupt source)
  398. * 2) setup xtime based on rtc_mips_get_time().
  399. * 3) choose a appropriate gettimeoffset routine.
  400. * 4) calculate a couple of cached variables for later usage
  401. * 5) plat_timer_setup() -
  402. * a) (optional) over-write any choices made above by time_init().
  403. * b) machine specific code should setup the timer irqaction.
  404. * c) enable the timer interrupt
  405. */
  406. void (*board_time_init)(void);
  407. unsigned int mips_hpt_frequency;
  408. static struct irqaction timer_irqaction = {
  409. .handler = timer_interrupt,
  410. .flags = IRQF_DISABLED,
  411. .name = "timer",
  412. };
  413. static unsigned int __init calibrate_hpt(void)
  414. {
  415. u64 frequency;
  416. u32 hpt_start, hpt_end, hpt_count, hz;
  417. const int loops = HZ / 10;
  418. int log_2_loops = 0;
  419. int i;
  420. /*
  421. * We want to calibrate for 0.1s, but to avoid a 64-bit
  422. * division we round the number of loops up to the nearest
  423. * power of 2.
  424. */
  425. while (loops > 1 << log_2_loops)
  426. log_2_loops++;
  427. i = 1 << log_2_loops;
  428. /*
  429. * Wait for a rising edge of the timer interrupt.
  430. */
  431. while (mips_timer_state());
  432. while (!mips_timer_state());
  433. /*
  434. * Now see how many high precision timer ticks happen
  435. * during the calculated number of periods between timer
  436. * interrupts.
  437. */
  438. hpt_start = mips_hpt_read();
  439. do {
  440. while (mips_timer_state());
  441. while (!mips_timer_state());
  442. } while (--i);
  443. hpt_end = mips_hpt_read();
  444. hpt_count = hpt_end - hpt_start;
  445. hz = HZ;
  446. frequency = (u64)hpt_count * (u64)hz;
  447. return frequency >> log_2_loops;
  448. }
  449. void __init time_init(void)
  450. {
  451. if (board_time_init)
  452. board_time_init();
  453. if (!rtc_mips_set_mmss)
  454. rtc_mips_set_mmss = rtc_mips_set_time;
  455. xtime.tv_sec = rtc_mips_get_time();
  456. xtime.tv_nsec = 0;
  457. set_normalized_timespec(&wall_to_monotonic,
  458. -xtime.tv_sec, -xtime.tv_nsec);
  459. /* Choose appropriate high precision timer routines. */
  460. if (!cpu_has_counter && !mips_hpt_read) {
  461. /* No high precision timer -- sorry. */
  462. mips_hpt_read = null_hpt_read;
  463. mips_hpt_init = null_hpt_init;
  464. } else if (!mips_hpt_frequency && !mips_timer_state) {
  465. /* A high precision timer of unknown frequency. */
  466. if (!mips_hpt_read) {
  467. /* No external high precision timer -- use R4k. */
  468. mips_hpt_read = c0_hpt_read;
  469. mips_hpt_init = c0_hpt_init;
  470. }
  471. if (cpu_has_mips32r1 || cpu_has_mips32r2 ||
  472. (current_cpu_data.isa_level == MIPS_CPU_ISA_I) ||
  473. (current_cpu_data.isa_level == MIPS_CPU_ISA_II))
  474. /*
  475. * We need to calibrate the counter but we don't have
  476. * 64-bit division.
  477. */
  478. do_gettimeoffset = calibrate_div32_gettimeoffset;
  479. else
  480. /*
  481. * We need to calibrate the counter but we *do* have
  482. * 64-bit division.
  483. */
  484. do_gettimeoffset = calibrate_div64_gettimeoffset;
  485. } else {
  486. /* We know counter frequency. Or we can get it. */
  487. if (!mips_hpt_read) {
  488. /* No external high precision timer -- use R4k. */
  489. mips_hpt_read = c0_hpt_read;
  490. if (mips_timer_state)
  491. mips_hpt_init = c0_hpt_init;
  492. else {
  493. /* No external timer interrupt -- use R4k. */
  494. mips_hpt_init = c0_hpt_timer_init;
  495. mips_timer_ack = c0_timer_ack;
  496. }
  497. }
  498. if (!mips_hpt_frequency)
  499. mips_hpt_frequency = calibrate_hpt();
  500. do_gettimeoffset = fixed_rate_gettimeoffset;
  501. /* Calculate cache parameters. */
  502. cycles_per_jiffy = (mips_hpt_frequency + HZ / 2) / HZ;
  503. /* sll32_usecs_per_cycle = 10^6 * 2^32 / mips_counter_freq */
  504. do_div64_32(sll32_usecs_per_cycle,
  505. 1000000, mips_hpt_frequency / 2,
  506. mips_hpt_frequency);
  507. /* Report the high precision timer rate for a reference. */
  508. printk("Using %u.%03u MHz high precision timer.\n",
  509. ((mips_hpt_frequency + 500) / 1000) / 1000,
  510. ((mips_hpt_frequency + 500) / 1000) % 1000);
  511. }
  512. if (!mips_timer_ack)
  513. /* No timer interrupt ack (e.g. i8254). */
  514. mips_timer_ack = null_timer_ack;
  515. /* This sets up the high precision timer for the first interrupt. */
  516. mips_hpt_init(mips_hpt_read());
  517. /*
  518. * Call board specific timer interrupt setup.
  519. *
  520. * this pointer must be setup in machine setup routine.
  521. *
  522. * Even if a machine chooses to use a low-level timer interrupt,
  523. * it still needs to setup the timer_irqaction.
  524. * In that case, it might be better to set timer_irqaction.handler
  525. * to be NULL function so that we are sure the high-level code
  526. * is not invoked accidentally.
  527. */
  528. plat_timer_setup(&timer_irqaction);
  529. }
  530. #define FEBRUARY 2
  531. #define STARTOFTIME 1970
  532. #define SECDAY 86400L
  533. #define SECYR (SECDAY * 365)
  534. #define leapyear(y) ((!((y) % 4) && ((y) % 100)) || !((y) % 400))
  535. #define days_in_year(y) (leapyear(y) ? 366 : 365)
  536. #define days_in_month(m) (month_days[(m) - 1])
  537. static int month_days[12] = {
  538. 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  539. };
  540. void to_tm(unsigned long tim, struct rtc_time *tm)
  541. {
  542. long hms, day, gday;
  543. int i;
  544. gday = day = tim / SECDAY;
  545. hms = tim % SECDAY;
  546. /* Hours, minutes, seconds are easy */
  547. tm->tm_hour = hms / 3600;
  548. tm->tm_min = (hms % 3600) / 60;
  549. tm->tm_sec = (hms % 3600) % 60;
  550. /* Number of years in days */
  551. for (i = STARTOFTIME; day >= days_in_year(i); i++)
  552. day -= days_in_year(i);
  553. tm->tm_year = i;
  554. /* Number of months in days left */
  555. if (leapyear(tm->tm_year))
  556. days_in_month(FEBRUARY) = 29;
  557. for (i = 1; day >= days_in_month(i); i++)
  558. day -= days_in_month(i);
  559. days_in_month(FEBRUARY) = 28;
  560. tm->tm_mon = i - 1; /* tm_mon starts from 0 to 11 */
  561. /* Days are what is left over (+1) from all that. */
  562. tm->tm_mday = day + 1;
  563. /*
  564. * Determine the day of week
  565. */
  566. tm->tm_wday = (gday + 4) % 7; /* 1970/1/1 was Thursday */
  567. }
  568. EXPORT_SYMBOL(rtc_lock);
  569. EXPORT_SYMBOL(to_tm);
  570. EXPORT_SYMBOL(rtc_mips_set_time);
  571. EXPORT_SYMBOL(rtc_mips_get_time);
  572. unsigned long long sched_clock(void)
  573. {
  574. return (unsigned long long)jiffies*(1000000000/HZ);
  575. }