clk-atlas6.c 3.4 KB

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