clock.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * linux/arch/arm/mach-aaec2000/clock.c
  3. *
  4. * Copyright (C) 2005 Nicolas Bellido Y Ortega
  5. *
  6. * Based on linux/arch/arm/mach-integrator/clock.c
  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/module.h>
  13. #include <linux/kernel.h>
  14. #include <linux/list.h>
  15. #include <linux/errno.h>
  16. #include <linux/err.h>
  17. #include <linux/string.h>
  18. #include <linux/clk.h>
  19. #include <linux/mutex.h>
  20. #include "clock.h"
  21. static LIST_HEAD(clocks);
  22. static DEFINE_MUTEX(clocks_mutex);
  23. struct clk *clk_get(struct device *dev, const char *id)
  24. {
  25. struct clk *p, *clk = ERR_PTR(-ENOENT);
  26. mutex_lock(&clocks_mutex);
  27. list_for_each_entry(p, &clocks, node) {
  28. if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
  29. clk = p;
  30. break;
  31. }
  32. }
  33. mutex_unlock(&clocks_mutex);
  34. return clk;
  35. }
  36. EXPORT_SYMBOL(clk_get);
  37. void clk_put(struct clk *clk)
  38. {
  39. module_put(clk->owner);
  40. }
  41. EXPORT_SYMBOL(clk_put);
  42. int clk_enable(struct clk *clk)
  43. {
  44. return 0;
  45. }
  46. EXPORT_SYMBOL(clk_enable);
  47. void clk_disable(struct clk *clk)
  48. {
  49. }
  50. EXPORT_SYMBOL(clk_disable);
  51. unsigned long clk_get_rate(struct clk *clk)
  52. {
  53. return clk->rate;
  54. }
  55. EXPORT_SYMBOL(clk_get_rate);
  56. long clk_round_rate(struct clk *clk, unsigned long rate)
  57. {
  58. return rate;
  59. }
  60. EXPORT_SYMBOL(clk_round_rate);
  61. int clk_set_rate(struct clk *clk, unsigned long rate)
  62. {
  63. return 0;
  64. }
  65. EXPORT_SYMBOL(clk_set_rate);
  66. int clk_register(struct clk *clk)
  67. {
  68. mutex_lock(&clocks_mutex);
  69. list_add(&clk->node, &clocks);
  70. mutex_unlock(&clocks_mutex);
  71. return 0;
  72. }
  73. EXPORT_SYMBOL(clk_register);
  74. void clk_unregister(struct clk *clk)
  75. {
  76. mutex_lock(&clocks_mutex);
  77. list_del(&clk->node);
  78. mutex_unlock(&clocks_mutex);
  79. }
  80. EXPORT_SYMBOL(clk_unregister);
  81. static int __init clk_init(void)
  82. {
  83. return 0;
  84. }
  85. arch_initcall(clk_init);