clock.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2009 ST-Ericsson
  3. * heavily based on realview platform
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/module.h>
  10. #include <linux/kernel.h>
  11. #include <linux/list.h>
  12. #include <linux/errno.h>
  13. #include <linux/err.h>
  14. #include <linux/clk.h>
  15. #include <linux/mutex.h>
  16. #include <asm/clkdev.h>
  17. /* currently the clk structure
  18. * just supports rate. This would
  19. * be extended as and when new devices are
  20. * added - TODO
  21. */
  22. struct clk {
  23. unsigned long rate;
  24. };
  25. int clk_enable(struct clk *clk)
  26. {
  27. return 0;
  28. }
  29. EXPORT_SYMBOL(clk_enable);
  30. void clk_disable(struct clk *clk)
  31. {
  32. }
  33. EXPORT_SYMBOL(clk_disable);
  34. unsigned long clk_get_rate(struct clk *clk)
  35. {
  36. return clk->rate;
  37. }
  38. EXPORT_SYMBOL(clk_get_rate);
  39. long clk_round_rate(struct clk *clk, unsigned long rate)
  40. {
  41. /*TODO*/
  42. return rate;
  43. }
  44. EXPORT_SYMBOL(clk_round_rate);
  45. int clk_set_rate(struct clk *clk, unsigned long rate)
  46. {
  47. clk->rate = rate;
  48. return 0;
  49. }
  50. EXPORT_SYMBOL(clk_set_rate);
  51. /* ssp clock */
  52. static struct clk ssp_clk = {
  53. .rate = 48000000,
  54. };
  55. /* fixed clock */
  56. static struct clk f38_clk = {
  57. .rate = 38400000,
  58. };
  59. static struct clk_lookup lookups[] = {
  60. {
  61. /* UART0 */
  62. .dev_id = "uart0",
  63. .clk = &f38_clk,
  64. }, { /* UART1 */
  65. .dev_id = "uart1",
  66. .clk = &f38_clk,
  67. }, { /* UART2 */
  68. .dev_id = "uart2",
  69. .clk = &f38_clk,
  70. }, { /* SSP */
  71. .dev_id = "pl022",
  72. .clk = &ssp_clk,
  73. }
  74. };
  75. static int __init clk_init(void)
  76. {
  77. int i;
  78. /* register the clock lookups */
  79. for (i = 0; i < ARRAY_SIZE(lookups); i++)
  80. clkdev_add(&lookups[i]);
  81. return 0;
  82. }
  83. arch_initcall(clk_init);