clk-atlas6.c 3.4 KB

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