clock.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * linux/arch/arm/mach-w90x900/clock.c
  3. *
  4. * Copyright (c) 2008 Nuvoton technology corporation
  5. *
  6. * Wan ZongShun <mcuos.com@gmail.com>
  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 as published by
  10. * the Free Software Foundation; either version 2 of the License.
  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/spinlock.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/io.h>
  22. #include <mach/hardware.h>
  23. #include "clock.h"
  24. #define SUBCLK 0x24
  25. static DEFINE_SPINLOCK(clocks_lock);
  26. int clk_enable(struct clk *clk)
  27. {
  28. unsigned long flags;
  29. spin_lock_irqsave(&clocks_lock, flags);
  30. if (clk->enabled++ == 0)
  31. (clk->enable)(clk, 1);
  32. spin_unlock_irqrestore(&clocks_lock, flags);
  33. return 0;
  34. }
  35. EXPORT_SYMBOL(clk_enable);
  36. void clk_disable(struct clk *clk)
  37. {
  38. unsigned long flags;
  39. if (!clk)
  40. return;
  41. WARN_ON(clk->enabled == 0);
  42. spin_lock_irqsave(&clocks_lock, flags);
  43. if (--clk->enabled == 0)
  44. (clk->enable)(clk, 0);
  45. spin_unlock_irqrestore(&clocks_lock, flags);
  46. }
  47. EXPORT_SYMBOL(clk_disable);
  48. unsigned long clk_get_rate(struct clk *clk)
  49. {
  50. return 15000000;
  51. }
  52. EXPORT_SYMBOL(clk_get_rate);
  53. void nuc900_clk_enable(struct clk *clk, int enable)
  54. {
  55. unsigned int clocks = clk->cken;
  56. unsigned long clken;
  57. clken = __raw_readl(W90X900_VA_CLKPWR);
  58. if (enable)
  59. clken |= clocks;
  60. else
  61. clken &= ~clocks;
  62. __raw_writel(clken, W90X900_VA_CLKPWR);
  63. }
  64. void nuc900_subclk_enable(struct clk *clk, int enable)
  65. {
  66. unsigned int clocks = clk->cken;
  67. unsigned long clken;
  68. clken = __raw_readl(W90X900_VA_CLKPWR + SUBCLK);
  69. if (enable)
  70. clken |= clocks;
  71. else
  72. clken &= ~clocks;
  73. __raw_writel(clken, W90X900_VA_CLKPWR + SUBCLK);
  74. }
  75. /* dummy functions, should not be called */
  76. long clk_round_rate(struct clk *clk, unsigned long rate)
  77. {
  78. WARN_ON(clk);
  79. return 0;
  80. }
  81. EXPORT_SYMBOL(clk_round_rate);
  82. int clk_set_rate(struct clk *clk, unsigned long rate)
  83. {
  84. WARN_ON(clk);
  85. return 0;
  86. }
  87. EXPORT_SYMBOL(clk_set_rate);
  88. int clk_set_parent(struct clk *clk, struct clk *parent)
  89. {
  90. WARN_ON(clk);
  91. return 0;
  92. }
  93. EXPORT_SYMBOL(clk_set_parent);
  94. struct clk *clk_get_parent(struct clk *clk)
  95. {
  96. WARN_ON(clk);
  97. return NULL;
  98. }
  99. EXPORT_SYMBOL(clk_get_parent);