profile.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* MN10300 Profiling setup
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. /*
  12. * initialise the profiling if enabled
  13. * - using with gdbstub will give anomalous results
  14. * - can't be used with gdbstub if running at IRQ priority 0
  15. */
  16. static __init int profile_init(void)
  17. {
  18. u16 tmp;
  19. if (!prof_buffer)
  20. return 0;
  21. /* use timer 11 to drive the profiling interrupts */
  22. set_intr_stub(EXCEP_IRQ_LEVEL0, profile_handler);
  23. /* set IRQ priority at which to run */
  24. set_intr_level(TM11IRQ, GxICR_LEVEL_0);
  25. /* set up timer 11
  26. * - source: (IOCLK 33MHz)*2 = 66MHz
  27. * - frequency: (33330000*2) / 8 / 20625 = 202Hz
  28. */
  29. TM11BR = 20625 - 1;
  30. TM11MD = TM8MD_SRC_IOCLK_8;
  31. TM11MD |= TM8MD_INIT_COUNTER;
  32. TM11MD &= ~TM8MD_INIT_COUNTER;
  33. TM11MD |= TM8MD_COUNT_ENABLE;
  34. TM11ICR |= GxICR_ENABLE;
  35. tmp = TM11ICR;
  36. printk(KERN_INFO "Profiling initiated on timer 11, priority 0, %uHz\n",
  37. MN10300_IOCLK / 8 / (TM11BR + 1));
  38. printk(KERN_INFO "Profile histogram stored %p-%p\n",
  39. prof_buffer, (u8 *)(prof_buffer + prof_len) - 1);
  40. return 0;
  41. }
  42. __initcall(profile_init);