clock-mmp2.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/init.h>
  4. #include <linux/list.h>
  5. #include <linux/io.h>
  6. #include <linux/clk.h>
  7. #include <linux/clk/mmp.h>
  8. #include "addr-map.h"
  9. #include "common.h"
  10. #include "clock.h"
  11. /*
  12. * APB Clock register offsets for MMP2
  13. */
  14. #define APBC_RTC APBC_REG(0x000)
  15. #define APBC_TWSI1 APBC_REG(0x004)
  16. #define APBC_TWSI2 APBC_REG(0x008)
  17. #define APBC_TWSI3 APBC_REG(0x00c)
  18. #define APBC_TWSI4 APBC_REG(0x010)
  19. #define APBC_KPC APBC_REG(0x018)
  20. #define APBC_UART1 APBC_REG(0x02c)
  21. #define APBC_UART2 APBC_REG(0x030)
  22. #define APBC_UART3 APBC_REG(0x034)
  23. #define APBC_GPIO APBC_REG(0x038)
  24. #define APBC_PWM0 APBC_REG(0x03c)
  25. #define APBC_PWM1 APBC_REG(0x040)
  26. #define APBC_PWM2 APBC_REG(0x044)
  27. #define APBC_PWM3 APBC_REG(0x048)
  28. #define APBC_SSP0 APBC_REG(0x04c)
  29. #define APBC_SSP1 APBC_REG(0x050)
  30. #define APBC_SSP2 APBC_REG(0x054)
  31. #define APBC_SSP3 APBC_REG(0x058)
  32. #define APBC_SSP4 APBC_REG(0x05c)
  33. #define APBC_SSP5 APBC_REG(0x060)
  34. #define APBC_TWSI5 APBC_REG(0x07c)
  35. #define APBC_TWSI6 APBC_REG(0x080)
  36. #define APBC_UART4 APBC_REG(0x088)
  37. #define APMU_USB APMU_REG(0x05c)
  38. #define APMU_NAND APMU_REG(0x060)
  39. #define APMU_SDH0 APMU_REG(0x054)
  40. #define APMU_SDH1 APMU_REG(0x058)
  41. #define APMU_SDH2 APMU_REG(0x0e8)
  42. #define APMU_SDH3 APMU_REG(0x0ec)
  43. static void sdhc_clk_enable(struct clk *clk)
  44. {
  45. uint32_t clk_rst;
  46. clk_rst = __raw_readl(clk->clk_rst);
  47. clk_rst |= clk->enable_val;
  48. __raw_writel(clk_rst, clk->clk_rst);
  49. }
  50. static void sdhc_clk_disable(struct clk *clk)
  51. {
  52. uint32_t clk_rst;
  53. clk_rst = __raw_readl(clk->clk_rst);
  54. clk_rst &= ~clk->enable_val;
  55. __raw_writel(clk_rst, clk->clk_rst);
  56. }
  57. struct clkops sdhc_clk_ops = {
  58. .enable = sdhc_clk_enable,
  59. .disable = sdhc_clk_disable,
  60. };
  61. /* APB peripheral clocks */
  62. static APBC_CLK(uart1, UART1, 1, 26000000);
  63. static APBC_CLK(uart2, UART2, 1, 26000000);
  64. static APBC_CLK(uart3, UART3, 1, 26000000);
  65. static APBC_CLK(uart4, UART4, 1, 26000000);
  66. static APBC_CLK(twsi1, TWSI1, 0, 26000000);
  67. static APBC_CLK(twsi2, TWSI2, 0, 26000000);
  68. static APBC_CLK(twsi3, TWSI3, 0, 26000000);
  69. static APBC_CLK(twsi4, TWSI4, 0, 26000000);
  70. static APBC_CLK(twsi5, TWSI5, 0, 26000000);
  71. static APBC_CLK(twsi6, TWSI6, 0, 26000000);
  72. static APBC_CLK(gpio, GPIO, 0, 26000000);
  73. static APMU_CLK(nand, NAND, 0xbf, 100000000);
  74. static APMU_CLK_OPS(sdh0, SDH0, 0x1b, 200000000, &sdhc_clk_ops);
  75. static APMU_CLK_OPS(sdh1, SDH1, 0x1b, 200000000, &sdhc_clk_ops);
  76. static APMU_CLK_OPS(sdh2, SDH2, 0x1b, 200000000, &sdhc_clk_ops);
  77. static APMU_CLK_OPS(sdh3, SDH3, 0x1b, 200000000, &sdhc_clk_ops);
  78. static struct clk_lookup mmp2_clkregs[] = {
  79. INIT_CLKREG(&clk_uart1, "pxa2xx-uart.0", NULL),
  80. INIT_CLKREG(&clk_uart2, "pxa2xx-uart.1", NULL),
  81. INIT_CLKREG(&clk_uart3, "pxa2xx-uart.2", NULL),
  82. INIT_CLKREG(&clk_uart4, "pxa2xx-uart.3", NULL),
  83. INIT_CLKREG(&clk_twsi1, "pxa2xx-i2c.0", NULL),
  84. INIT_CLKREG(&clk_twsi2, "pxa2xx-i2c.1", NULL),
  85. INIT_CLKREG(&clk_twsi3, "pxa2xx-i2c.2", NULL),
  86. INIT_CLKREG(&clk_twsi4, "pxa2xx-i2c.3", NULL),
  87. INIT_CLKREG(&clk_twsi5, "pxa2xx-i2c.4", NULL),
  88. INIT_CLKREG(&clk_twsi6, "pxa2xx-i2c.5", NULL),
  89. INIT_CLKREG(&clk_nand, "pxa3xx-nand", NULL),
  90. INIT_CLKREG(&clk_gpio, "mmp2-gpio", NULL),
  91. INIT_CLKREG(&clk_sdh0, "sdhci-pxav3.0", "PXA-SDHCLK"),
  92. INIT_CLKREG(&clk_sdh1, "sdhci-pxav3.1", "PXA-SDHCLK"),
  93. INIT_CLKREG(&clk_sdh2, "sdhci-pxav3.2", "PXA-SDHCLK"),
  94. INIT_CLKREG(&clk_sdh3, "sdhci-pxav3.3", "PXA-SDHCLK"),
  95. };
  96. void __init mmp2_clk_init(phys_addr_t mpmu_phys, phys_addr_t apmu_phys,
  97. phys_addr_t apbc_phys)
  98. {
  99. clkdev_add_table(ARRAY_AND_SIZE(mmp2_clkregs));
  100. }