clk-mt2712-bdp.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (c) 2017 MediaTek Inc.
  3. * Author: Weiyi Lu <weiyi.lu@mediatek.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include <linux/clk-provider.h>
  15. #include <linux/platform_device.h>
  16. #include "clk-mtk.h"
  17. #include "clk-gate.h"
  18. #include <dt-bindings/clock/mt2712-clk.h>
  19. static const struct mtk_gate_regs bdp_cg_regs = {
  20. .set_ofs = 0x100,
  21. .clr_ofs = 0x100,
  22. .sta_ofs = 0x100,
  23. };
  24. #define GATE_BDP(_id, _name, _parent, _shift) { \
  25. .id = _id, \
  26. .name = _name, \
  27. .parent_name = _parent, \
  28. .regs = &bdp_cg_regs, \
  29. .shift = _shift, \
  30. .ops = &mtk_clk_gate_ops_no_setclr, \
  31. }
  32. static const struct mtk_gate bdp_clks[] = {
  33. GATE_BDP(CLK_BDP_BRIDGE_B, "bdp_bridge_b", "mm_sel", 0),
  34. GATE_BDP(CLK_BDP_BRIDGE_DRAM, "bdp_bridge_d", "mm_sel", 1),
  35. GATE_BDP(CLK_BDP_LARB_DRAM, "bdp_larb_d", "mm_sel", 2),
  36. GATE_BDP(CLK_BDP_WR_CHANNEL_VDI_PXL, "bdp_vdi_pxl", "tvd_sel", 3),
  37. GATE_BDP(CLK_BDP_WR_CHANNEL_VDI_DRAM, "bdp_vdi_d", "mm_sel", 4),
  38. GATE_BDP(CLK_BDP_WR_CHANNEL_VDI_B, "bdp_vdi_b", "mm_sel", 5),
  39. GATE_BDP(CLK_BDP_MT_B, "bdp_fmt_b", "mm_sel", 9),
  40. GATE_BDP(CLK_BDP_DISPFMT_27M, "bdp_27m", "di_sel", 10),
  41. GATE_BDP(CLK_BDP_DISPFMT_27M_VDOUT, "bdp_27m_vdout", "di_sel", 11),
  42. GATE_BDP(CLK_BDP_DISPFMT_27_74_74, "bdp_27_74_74", "di_sel", 12),
  43. GATE_BDP(CLK_BDP_DISPFMT_2FS, "bdp_2fs", "di_sel", 13),
  44. GATE_BDP(CLK_BDP_DISPFMT_2FS_2FS74_148, "bdp_2fs74_148", "di_sel", 14),
  45. GATE_BDP(CLK_BDP_DISPFMT_B, "bdp_b", "mm_sel", 15),
  46. GATE_BDP(CLK_BDP_VDO_DRAM, "bdp_vdo_d", "mm_sel", 16),
  47. GATE_BDP(CLK_BDP_VDO_2FS, "bdp_vdo_2fs", "di_sel", 17),
  48. GATE_BDP(CLK_BDP_VDO_B, "bdp_vdo_b", "mm_sel", 18),
  49. GATE_BDP(CLK_BDP_WR_CHANNEL_DI_PXL, "bdp_di_pxl", "di_sel", 19),
  50. GATE_BDP(CLK_BDP_WR_CHANNEL_DI_DRAM, "bdp_di_d", "mm_sel", 20),
  51. GATE_BDP(CLK_BDP_WR_CHANNEL_DI_B, "bdp_di_b", "mm_sel", 21),
  52. GATE_BDP(CLK_BDP_NR_AGENT, "bdp_nr_agent", "nr_sel", 22),
  53. GATE_BDP(CLK_BDP_NR_DRAM, "bdp_nr_d", "mm_sel", 23),
  54. GATE_BDP(CLK_BDP_NR_B, "bdp_nr_b", "mm_sel", 24),
  55. GATE_BDP(CLK_BDP_BRIDGE_RT_B, "bdp_bridge_rt_b", "mm_sel", 25),
  56. GATE_BDP(CLK_BDP_BRIDGE_RT_DRAM, "bdp_bridge_rt_d", "mm_sel", 26),
  57. GATE_BDP(CLK_BDP_LARB_RT_DRAM, "bdp_larb_rt_d", "mm_sel", 27),
  58. GATE_BDP(CLK_BDP_TVD_TDC, "bdp_tvd_tdc", "mm_sel", 28),
  59. GATE_BDP(CLK_BDP_TVD_54, "bdp_tvd_clk_54", "tvd_sel", 29),
  60. GATE_BDP(CLK_BDP_TVD_CBUS, "bdp_tvd_cbus", "mm_sel", 30),
  61. };
  62. static int clk_mt2712_bdp_probe(struct platform_device *pdev)
  63. {
  64. struct clk_onecell_data *clk_data;
  65. int r;
  66. struct device_node *node = pdev->dev.of_node;
  67. clk_data = mtk_alloc_clk_data(CLK_BDP_NR_CLK);
  68. mtk_clk_register_gates(node, bdp_clks, ARRAY_SIZE(bdp_clks),
  69. clk_data);
  70. r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
  71. if (r != 0)
  72. pr_err("%s(): could not register clock provider: %d\n",
  73. __func__, r);
  74. return r;
  75. }
  76. static const struct of_device_id of_match_clk_mt2712_bdp[] = {
  77. { .compatible = "mediatek,mt2712-bdpsys", },
  78. {}
  79. };
  80. static struct platform_driver clk_mt2712_bdp_drv = {
  81. .probe = clk_mt2712_bdp_probe,
  82. .driver = {
  83. .name = "clk-mt2712-bdp",
  84. .of_match_table = of_match_clk_mt2712_bdp,
  85. },
  86. };
  87. builtin_platform_driver(clk_mt2712_bdp_drv);