s3c24xx-cpufreq-debugfs.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * Copyright (c) 2009 Simtec Electronics
  3. * http://armlinux.simtec.co.uk/
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * S3C24XX CPU Frequency scaling - debugfs status support
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/export.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/ioport.h>
  16. #include <linux/cpufreq.h>
  17. #include <linux/debugfs.h>
  18. #include <linux/seq_file.h>
  19. #include <linux/err.h>
  20. #include <plat/cpu-freq-core.h>
  21. static struct dentry *dbgfs_root;
  22. static struct dentry *dbgfs_file_io;
  23. static struct dentry *dbgfs_file_info;
  24. static struct dentry *dbgfs_file_board;
  25. #define print_ns(x) ((x) / 10), ((x) % 10)
  26. static void show_max(struct seq_file *seq, struct s3c_freq *f)
  27. {
  28. seq_printf(seq, "MAX: F=%lu, H=%lu, P=%lu, A=%lu\n",
  29. f->fclk, f->hclk, f->pclk, f->armclk);
  30. }
  31. static int board_show(struct seq_file *seq, void *p)
  32. {
  33. struct s3c_cpufreq_config *cfg;
  34. struct s3c_cpufreq_board *brd;
  35. cfg = s3c_cpufreq_getconfig();
  36. if (!cfg) {
  37. seq_printf(seq, "no configuration registered\n");
  38. return 0;
  39. }
  40. brd = cfg->board;
  41. if (!brd) {
  42. seq_printf(seq, "no board definition set?\n");
  43. return 0;
  44. }
  45. seq_printf(seq, "SDRAM refresh %u ns\n", brd->refresh);
  46. seq_printf(seq, "auto_io=%u\n", brd->auto_io);
  47. seq_printf(seq, "need_io=%u\n", brd->need_io);
  48. show_max(seq, &brd->max);
  49. return 0;
  50. }
  51. static int fops_board_open(struct inode *inode, struct file *file)
  52. {
  53. return single_open(file, board_show, NULL);
  54. }
  55. static const struct file_operations fops_board = {
  56. .open = fops_board_open,
  57. .read = seq_read,
  58. .llseek = seq_lseek,
  59. .release = single_release,
  60. .owner = THIS_MODULE,
  61. };
  62. static int info_show(struct seq_file *seq, void *p)
  63. {
  64. struct s3c_cpufreq_config *cfg;
  65. cfg = s3c_cpufreq_getconfig();
  66. if (!cfg) {
  67. seq_printf(seq, "no configuration registered\n");
  68. return 0;
  69. }
  70. seq_printf(seq, " FCLK %ld Hz\n", cfg->freq.fclk);
  71. seq_printf(seq, " HCLK %ld Hz (%lu.%lu ns)\n",
  72. cfg->freq.hclk, print_ns(cfg->freq.hclk_tns));
  73. seq_printf(seq, " PCLK %ld Hz\n", cfg->freq.hclk);
  74. seq_printf(seq, "ARMCLK %ld Hz\n", cfg->freq.armclk);
  75. seq_printf(seq, "\n");
  76. show_max(seq, &cfg->max);
  77. seq_printf(seq, "Divisors: P=%d, H=%d, A=%d, dvs=%s\n",
  78. cfg->divs.h_divisor, cfg->divs.p_divisor,
  79. cfg->divs.arm_divisor, cfg->divs.dvs ? "on" : "off");
  80. seq_printf(seq, "\n");
  81. seq_printf(seq, "lock_pll=%u\n", cfg->lock_pll);
  82. return 0;
  83. }
  84. static int fops_info_open(struct inode *inode, struct file *file)
  85. {
  86. return single_open(file, info_show, NULL);
  87. }
  88. static const struct file_operations fops_info = {
  89. .open = fops_info_open,
  90. .read = seq_read,
  91. .llseek = seq_lseek,
  92. .release = single_release,
  93. .owner = THIS_MODULE,
  94. };
  95. static int io_show(struct seq_file *seq, void *p)
  96. {
  97. void (*show_bank)(struct seq_file *, struct s3c_cpufreq_config *, union s3c_iobank *);
  98. struct s3c_cpufreq_config *cfg;
  99. struct s3c_iotimings *iot;
  100. union s3c_iobank *iob;
  101. int bank;
  102. cfg = s3c_cpufreq_getconfig();
  103. if (!cfg) {
  104. seq_printf(seq, "no configuration registered\n");
  105. return 0;
  106. }
  107. show_bank = cfg->info->debug_io_show;
  108. if (!show_bank) {
  109. seq_printf(seq, "no code to show bank timing\n");
  110. return 0;
  111. }
  112. iot = s3c_cpufreq_getiotimings();
  113. if (!iot) {
  114. seq_printf(seq, "no io timings registered\n");
  115. return 0;
  116. }
  117. seq_printf(seq, "hclk period is %lu.%lu ns\n", print_ns(cfg->freq.hclk_tns));
  118. for (bank = 0; bank < MAX_BANKS; bank++) {
  119. iob = &iot->bank[bank];
  120. seq_printf(seq, "bank %d: ", bank);
  121. if (!iob->io_2410) {
  122. seq_printf(seq, "nothing set\n");
  123. continue;
  124. }
  125. show_bank(seq, cfg, iob);
  126. }
  127. return 0;
  128. }
  129. static int fops_io_open(struct inode *inode, struct file *file)
  130. {
  131. return single_open(file, io_show, NULL);
  132. }
  133. static const struct file_operations fops_io = {
  134. .open = fops_io_open,
  135. .read = seq_read,
  136. .llseek = seq_lseek,
  137. .release = single_release,
  138. .owner = THIS_MODULE,
  139. };
  140. static int __init s3c_freq_debugfs_init(void)
  141. {
  142. dbgfs_root = debugfs_create_dir("s3c-cpufreq", NULL);
  143. if (IS_ERR(dbgfs_root)) {
  144. printk(KERN_ERR "%s: error creating debugfs root\n", __func__);
  145. return PTR_ERR(dbgfs_root);
  146. }
  147. dbgfs_file_io = debugfs_create_file("io-timing", S_IRUGO, dbgfs_root,
  148. NULL, &fops_io);
  149. dbgfs_file_info = debugfs_create_file("info", S_IRUGO, dbgfs_root,
  150. NULL, &fops_info);
  151. dbgfs_file_board = debugfs_create_file("board", S_IRUGO, dbgfs_root,
  152. NULL, &fops_board);
  153. return 0;
  154. }
  155. late_initcall(s3c_freq_debugfs_init);