clocks.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* arch/arm/mach-lh7a40x/clocks.c
  2. *
  3. * Copyright (C) 2004 Marc Singer
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * version 2 as published by the Free Software Foundation.
  8. *
  9. */
  10. #include <mach/hardware.h>
  11. #include <mach/clocks.h>
  12. #include <linux/err.h>
  13. #include <linux/device.h>
  14. #include <linux/string.h>
  15. struct module;
  16. struct clk {
  17. struct list_head node;
  18. unsigned long rate;
  19. struct module *owner;
  20. const char *name;
  21. };
  22. /* ----- */
  23. #define MAINDIV1(c) (((c) >> 7) & 0x0f)
  24. #define MAINDIV2(c) (((c) >> 11) & 0x1f)
  25. #define PS(c) (((c) >> 18) & 0x03)
  26. #define PREDIV(c) (((c) >> 2) & 0x1f)
  27. #define HCLKDIV(c) (((c) >> 0) & 0x02)
  28. #define PCLKDIV(c) (((c) >> 16) & 0x03)
  29. unsigned int fclkfreq_get (void)
  30. {
  31. unsigned int clkset = CSC_CLKSET;
  32. unsigned int gclk
  33. = XTAL_IN
  34. / (1 << PS(clkset))
  35. * (MAINDIV1(clkset) + 2)
  36. / (PREDIV(clkset) + 2)
  37. * (MAINDIV2(clkset) + 2)
  38. ;
  39. return gclk;
  40. }
  41. unsigned int hclkfreq_get (void)
  42. {
  43. unsigned int clkset = CSC_CLKSET;
  44. unsigned int hclk = fclkfreq_get () / (HCLKDIV(clkset) + 1);
  45. return hclk;
  46. }
  47. unsigned int pclkfreq_get (void)
  48. {
  49. unsigned int clkset = CSC_CLKSET;
  50. int pclkdiv = PCLKDIV(clkset);
  51. unsigned int pclk;
  52. if (pclkdiv == 0x3)
  53. pclkdiv = 0x2;
  54. pclk = hclkfreq_get () / (1 << pclkdiv);
  55. return pclk;
  56. }
  57. /* ----- */
  58. struct clk *clk_get (struct device *dev, const char *id)
  59. {
  60. return dev && strcmp(dev_name(dev), "cldc-lh7a40x") == 0
  61. ? NULL : ERR_PTR(-ENOENT);
  62. }
  63. EXPORT_SYMBOL(clk_get);
  64. void clk_put (struct clk *clk)
  65. {
  66. }
  67. EXPORT_SYMBOL(clk_put);
  68. int clk_enable (struct clk *clk)
  69. {
  70. return 0;
  71. }
  72. EXPORT_SYMBOL(clk_enable);
  73. void clk_disable (struct clk *clk)
  74. {
  75. }
  76. EXPORT_SYMBOL(clk_disable);
  77. unsigned long clk_get_rate (struct clk *clk)
  78. {
  79. return 0;
  80. }
  81. EXPORT_SYMBOL(clk_get_rate);
  82. long clk_round_rate (struct clk *clk, unsigned long rate)
  83. {
  84. return rate;
  85. }
  86. EXPORT_SYMBOL(clk_round_rate);
  87. int clk_set_rate (struct clk *clk, unsigned long rate)
  88. {
  89. return -EIO;
  90. }
  91. EXPORT_SYMBOL(clk_set_rate);