clk-mt8192-mm.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. //
  3. // Copyright (c) 2021 MediaTek Inc.
  4. // Author: Chun-Jie Chen <[email protected]>
  5. #include <linux/clk-provider.h>
  6. #include <linux/platform_device.h>
  7. #include "clk-mtk.h"
  8. #include "clk-gate.h"
  9. #include <dt-bindings/clock/mt8192-clk.h>
  10. static const struct mtk_gate_regs mm0_cg_regs = {
  11. .set_ofs = 0x104,
  12. .clr_ofs = 0x108,
  13. .sta_ofs = 0x100,
  14. };
  15. static const struct mtk_gate_regs mm1_cg_regs = {
  16. .set_ofs = 0x114,
  17. .clr_ofs = 0x118,
  18. .sta_ofs = 0x110,
  19. };
  20. static const struct mtk_gate_regs mm2_cg_regs = {
  21. .set_ofs = 0x1a4,
  22. .clr_ofs = 0x1a8,
  23. .sta_ofs = 0x1a0,
  24. };
  25. #define GATE_MM0(_id, _name, _parent, _shift) \
  26. GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
  27. #define GATE_MM1(_id, _name, _parent, _shift) \
  28. GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
  29. #define GATE_MM2(_id, _name, _parent, _shift) \
  30. GATE_MTK(_id, _name, _parent, &mm2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
  31. static const struct mtk_gate mm_clks[] = {
  32. /* MM0 */
  33. GATE_MM0(CLK_MM_DISP_MUTEX0, "mm_disp_mutex0", "disp_sel", 0),
  34. GATE_MM0(CLK_MM_DISP_CONFIG, "mm_disp_config", "disp_sel", 1),
  35. GATE_MM0(CLK_MM_DISP_OVL0, "mm_disp_ovl0", "disp_sel", 2),
  36. GATE_MM0(CLK_MM_DISP_RDMA0, "mm_disp_rdma0", "disp_sel", 3),
  37. GATE_MM0(CLK_MM_DISP_OVL0_2L, "mm_disp_ovl0_2l", "disp_sel", 4),
  38. GATE_MM0(CLK_MM_DISP_WDMA0, "mm_disp_wdma0", "disp_sel", 5),
  39. GATE_MM0(CLK_MM_DISP_UFBC_WDMA0, "mm_disp_ufbc_wdma0", "disp_sel", 6),
  40. GATE_MM0(CLK_MM_DISP_RSZ0, "mm_disp_rsz0", "disp_sel", 7),
  41. GATE_MM0(CLK_MM_DISP_AAL0, "mm_disp_aal0", "disp_sel", 8),
  42. GATE_MM0(CLK_MM_DISP_CCORR0, "mm_disp_ccorr0", "disp_sel", 9),
  43. GATE_MM0(CLK_MM_DISP_DITHER0, "mm_disp_dither0", "disp_sel", 10),
  44. GATE_MM0(CLK_MM_SMI_INFRA, "mm_smi_infra", "disp_sel", 11),
  45. GATE_MM0(CLK_MM_DISP_GAMMA0, "mm_disp_gamma0", "disp_sel", 12),
  46. GATE_MM0(CLK_MM_DISP_POSTMASK0, "mm_disp_postmask0", "disp_sel", 13),
  47. GATE_MM0(CLK_MM_DISP_DSC_WRAP0, "mm_disp_dsc_wrap0", "disp_sel", 14),
  48. GATE_MM0(CLK_MM_DSI0, "mm_dsi0", "disp_sel", 15),
  49. GATE_MM0(CLK_MM_DISP_COLOR0, "mm_disp_color0", "disp_sel", 16),
  50. GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "disp_sel", 17),
  51. GATE_MM0(CLK_MM_DISP_FAKE_ENG0, "mm_disp_fake_eng0", "disp_sel", 18),
  52. GATE_MM0(CLK_MM_DISP_FAKE_ENG1, "mm_disp_fake_eng1", "disp_sel", 19),
  53. GATE_MM0(CLK_MM_MDP_TDSHP4, "mm_mdp_tdshp4", "disp_sel", 20),
  54. GATE_MM0(CLK_MM_MDP_RSZ4, "mm_mdp_rsz4", "disp_sel", 21),
  55. GATE_MM0(CLK_MM_MDP_AAL4, "mm_mdp_aal4", "disp_sel", 22),
  56. GATE_MM0(CLK_MM_MDP_HDR4, "mm_mdp_hdr4", "disp_sel", 23),
  57. GATE_MM0(CLK_MM_MDP_RDMA4, "mm_mdp_rdma4", "disp_sel", 24),
  58. GATE_MM0(CLK_MM_MDP_COLOR4, "mm_mdp_color4", "disp_sel", 25),
  59. GATE_MM0(CLK_MM_DISP_Y2R0, "mm_disp_y2r0", "disp_sel", 26),
  60. GATE_MM0(CLK_MM_SMI_GALS, "mm_smi_gals", "disp_sel", 27),
  61. GATE_MM0(CLK_MM_DISP_OVL2_2L, "mm_disp_ovl2_2l", "disp_sel", 28),
  62. GATE_MM0(CLK_MM_DISP_RDMA4, "mm_disp_rdma4", "disp_sel", 29),
  63. GATE_MM0(CLK_MM_DISP_DPI0, "mm_disp_dpi0", "disp_sel", 30),
  64. /* MM1 */
  65. GATE_MM1(CLK_MM_SMI_IOMMU, "mm_smi_iommu", "disp_sel", 0),
  66. /* MM2 */
  67. GATE_MM2(CLK_MM_DSI_DSI0, "mm_dsi_dsi0", "disp_sel", 0),
  68. GATE_MM2(CLK_MM_DPI_DPI0, "mm_dpi_dpi0", "dpi_sel", 8),
  69. GATE_MM2(CLK_MM_26MHZ, "mm_26mhz", "clk26m", 24),
  70. GATE_MM2(CLK_MM_32KHZ, "mm_32khz", "clk32k", 25),
  71. };
  72. static int clk_mt8192_mm_probe(struct platform_device *pdev)
  73. {
  74. struct device *dev = &pdev->dev;
  75. struct device_node *node = dev->parent->of_node;
  76. struct clk_hw_onecell_data *clk_data;
  77. int r;
  78. clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
  79. if (!clk_data)
  80. return -ENOMEM;
  81. r = mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks), clk_data);
  82. if (r)
  83. return r;
  84. return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
  85. }
  86. static struct platform_driver clk_mt8192_mm_drv = {
  87. .probe = clk_mt8192_mm_probe,
  88. .driver = {
  89. .name = "clk-mt8192-mm",
  90. },
  91. };
  92. builtin_platform_driver(clk_mt8192_mm_drv);