clk-prima2.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Clock tree for CSR SiRFprimaII
  3. *
  4. * Copyright (c) 2011 - 2014 Cambridge Silicon Radio Limited, a CSR plc group
  5. * company.
  6. *
  7. * Licensed under GPLv2 or later.
  8. */
  9. #include <linux/module.h>
  10. #include <linux/bitops.h>
  11. #include <linux/io.h>
  12. #include <linux/clkdev.h>
  13. #include <linux/clk-provider.h>
  14. #include <linux/of_address.h>
  15. #include <linux/syscore_ops.h>
  16. #include "prima2.h"
  17. #include "clk-common.c"
  18. static struct clk_dmn clk_mmc01 = {
  19. .regofs = SIRFSOC_CLKC_MMC_CFG,
  20. .enable_bit = 59,
  21. .hw = {
  22. .init = &clk_mmc01_init,
  23. },
  24. };
  25. static struct clk_dmn clk_mmc23 = {
  26. .regofs = SIRFSOC_CLKC_MMC_CFG,
  27. .enable_bit = 60,
  28. .hw = {
  29. .init = &clk_mmc23_init,
  30. },
  31. };
  32. static struct clk_dmn clk_mmc45 = {
  33. .regofs = SIRFSOC_CLKC_MMC_CFG,
  34. .enable_bit = 61,
  35. .hw = {
  36. .init = &clk_mmc45_init,
  37. },
  38. };
  39. static struct clk_init_data clk_nand_init = {
  40. .name = "nand",
  41. .ops = &ios_ops,
  42. .parent_names = std_clk_io_parents,
  43. .num_parents = ARRAY_SIZE(std_clk_io_parents),
  44. };
  45. static struct clk_std clk_nand = {
  46. .enable_bit = 34,
  47. .hw = {
  48. .init = &clk_nand_init,
  49. },
  50. };
  51. enum prima2_clk_index {
  52. /* 0 1 2 3 4 5 6 7 8 9 */
  53. rtc, osc, pll1, pll2, pll3, mem, sys, security, dsp, gps,
  54. mf, io, cpu, uart0, uart1, uart2, tsc, i2c0, i2c1, spi0,
  55. spi1, pwmc, efuse, pulse, dmac0, dmac1, nand, audio, usp0, usp1,
  56. usp2, vip, gfx, mm, lcd, vpp, mmc01, mmc23, mmc45, usbpll,
  57. usb0, usb1, cphif, maxclk,
  58. };
  59. static __initdata struct clk_hw *prima2_clk_hw_array[maxclk] = {
  60. NULL, /* dummy */
  61. NULL,
  62. &clk_pll1.hw,
  63. &clk_pll2.hw,
  64. &clk_pll3.hw,
  65. &clk_mem.hw,
  66. &clk_sys.hw,
  67. &clk_security.hw,
  68. &clk_dsp.hw,
  69. &clk_gps.hw,
  70. &clk_mf.hw,
  71. &clk_io.hw,
  72. &clk_cpu.hw,
  73. &clk_uart0.hw,
  74. &clk_uart1.hw,
  75. &clk_uart2.hw,
  76. &clk_tsc.hw,
  77. &clk_i2c0.hw,
  78. &clk_i2c1.hw,
  79. &clk_spi0.hw,
  80. &clk_spi1.hw,
  81. &clk_pwmc.hw,
  82. &clk_efuse.hw,
  83. &clk_pulse.hw,
  84. &clk_dmac0.hw,
  85. &clk_dmac1.hw,
  86. &clk_nand.hw,
  87. &clk_audio.hw,
  88. &clk_usp0.hw,
  89. &clk_usp1.hw,
  90. &clk_usp2.hw,
  91. &clk_vip.hw,
  92. &clk_gfx.hw,
  93. &clk_mm.hw,
  94. &clk_lcd.hw,
  95. &clk_vpp.hw,
  96. &clk_mmc01.hw,
  97. &clk_mmc23.hw,
  98. &clk_mmc45.hw,
  99. &usb_pll_clk_hw,
  100. &clk_usb0.hw,
  101. &clk_usb1.hw,
  102. &clk_cphif.hw,
  103. };
  104. static struct clk *prima2_clks[maxclk];
  105. static void __init prima2_clk_init(struct device_node *np)
  106. {
  107. struct device_node *rscnp;
  108. int i;
  109. rscnp = of_find_compatible_node(NULL, NULL, "sirf,prima2-rsc");
  110. sirfsoc_rsc_vbase = of_iomap(rscnp, 0);
  111. if (!sirfsoc_rsc_vbase)
  112. panic("unable to map rsc registers\n");
  113. of_node_put(rscnp);
  114. sirfsoc_clk_vbase = of_iomap(np, 0);
  115. if (!sirfsoc_clk_vbase)
  116. panic("unable to map clkc registers\n");
  117. /* These are always available (RTC and 26MHz OSC)*/
  118. prima2_clks[rtc] = clk_register_fixed_rate(NULL, "rtc", NULL, 0, 32768);
  119. prima2_clks[osc] = clk_register_fixed_rate(NULL, "osc", NULL, 0,
  120. 26000000);
  121. for (i = pll1; i < maxclk; i++) {
  122. prima2_clks[i] = clk_register(NULL, prima2_clk_hw_array[i]);
  123. BUG_ON(!prima2_clks[i]);
  124. }
  125. clk_register_clkdev(prima2_clks[cpu], NULL, "cpu");
  126. clk_register_clkdev(prima2_clks[io], NULL, "io");
  127. clk_register_clkdev(prima2_clks[mem], NULL, "mem");
  128. clk_register_clkdev(prima2_clks[mem], NULL, "osc");
  129. clk_data.clks = prima2_clks;
  130. clk_data.clk_num = maxclk;
  131. of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
  132. }
  133. CLK_OF_DECLARE(prima2_clk, "sirf,prima2-clkc", prima2_clk_init);