clk-realview.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Clock driver for the ARM RealView boards
  3. * Copyright (C) 2012 Linus Walleij
  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/clk.h>
  10. #include <linux/clkdev.h>
  11. #include <linux/err.h>
  12. #include <linux/io.h>
  13. #include <linux/clk-provider.h>
  14. #include <mach/hardware.h>
  15. #include <mach/platform.h>
  16. #include "clk-icst.h"
  17. /*
  18. * Implementation of the ARM RealView clock trees.
  19. */
  20. static const struct icst_params realview_oscvco_params = {
  21. .ref = 24000000,
  22. .vco_max = ICST307_VCO_MAX,
  23. .vco_min = ICST307_VCO_MIN,
  24. .vd_min = 4 + 8,
  25. .vd_max = 511 + 8,
  26. .rd_min = 1 + 2,
  27. .rd_max = 127 + 2,
  28. .s2div = icst307_s2div,
  29. .idx2s = icst307_idx2s,
  30. };
  31. static const struct clk_icst_desc __initdata realview_osc0_desc = {
  32. .params = &realview_oscvco_params,
  33. .vco_offset = REALVIEW_SYS_OSC0_OFFSET,
  34. .lock_offset = REALVIEW_SYS_LOCK_OFFSET,
  35. };
  36. static const struct clk_icst_desc __initdata realview_osc4_desc = {
  37. .params = &realview_oscvco_params,
  38. .vco_offset = REALVIEW_SYS_OSC4_OFFSET,
  39. .lock_offset = REALVIEW_SYS_LOCK_OFFSET,
  40. };
  41. /*
  42. * realview_clk_init() - set up the RealView clock tree
  43. */
  44. void __init realview_clk_init(void __iomem *sysbase, bool is_pb1176)
  45. {
  46. struct clk *clk;
  47. /* APB clock dummy */
  48. clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL, CLK_IS_ROOT, 0);
  49. clk_register_clkdev(clk, "apb_pclk", NULL);
  50. /* 24 MHz clock */
  51. clk = clk_register_fixed_rate(NULL, "clk24mhz", NULL, CLK_IS_ROOT,
  52. 24000000);
  53. clk_register_clkdev(clk, NULL, "dev:uart0");
  54. clk_register_clkdev(clk, NULL, "dev:uart1");
  55. clk_register_clkdev(clk, NULL, "dev:uart2");
  56. clk_register_clkdev(clk, NULL, "fpga:kmi0");
  57. clk_register_clkdev(clk, NULL, "fpga:kmi1");
  58. clk_register_clkdev(clk, NULL, "fpga:mmc0");
  59. clk_register_clkdev(clk, NULL, "dev:ssp0");
  60. if (is_pb1176) {
  61. /*
  62. * UART3 is on the dev chip in PB1176
  63. * UART4 only exists in PB1176
  64. */
  65. clk_register_clkdev(clk, NULL, "dev:uart3");
  66. clk_register_clkdev(clk, NULL, "dev:uart4");
  67. } else
  68. clk_register_clkdev(clk, NULL, "fpga:uart3");
  69. /* 1 MHz clock */
  70. clk = clk_register_fixed_rate(NULL, "clk1mhz", NULL, CLK_IS_ROOT,
  71. 1000000);
  72. clk_register_clkdev(clk, NULL, "sp804");
  73. /* ICST VCO clock */
  74. if (is_pb1176)
  75. clk = icst_clk_register(NULL, &realview_osc0_desc,
  76. "osc0", NULL, sysbase);
  77. else
  78. clk = icst_clk_register(NULL, &realview_osc4_desc,
  79. "osc4", NULL, sysbase);
  80. clk_register_clkdev(clk, NULL, "dev:clcd");
  81. clk_register_clkdev(clk, NULL, "issp:clcd");
  82. }