clk-mt8192-imp_iic_wrap.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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/of_device.h>
  7. #include <linux/platform_device.h>
  8. #include "clk-mtk.h"
  9. #include "clk-gate.h"
  10. #include <dt-bindings/clock/mt8192-clk.h>
  11. static const struct mtk_gate_regs imp_iic_wrap_cg_regs = {
  12. .set_ofs = 0xe08,
  13. .clr_ofs = 0xe04,
  14. .sta_ofs = 0xe00,
  15. };
  16. #define GATE_IMP_IIC_WRAP(_id, _name, _parent, _shift) \
  17. GATE_MTK_FLAGS(_id, _name, _parent, &imp_iic_wrap_cg_regs, _shift, \
  18. &mtk_clk_gate_ops_setclr, CLK_OPS_PARENT_ENABLE)
  19. static const struct mtk_gate imp_iic_wrap_c_clks[] = {
  20. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C10, "imp_iic_wrap_c_i2c10", "infra_i2c0", 0),
  21. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C11, "imp_iic_wrap_c_i2c11", "infra_i2c0", 1),
  22. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C12, "imp_iic_wrap_c_i2c12", "infra_i2c0", 2),
  23. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C13, "imp_iic_wrap_c_i2c13", "infra_i2c0", 3),
  24. };
  25. static const struct mtk_gate imp_iic_wrap_e_clks[] = {
  26. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_E_I2C3, "imp_iic_wrap_e_i2c3", "infra_i2c0", 0),
  27. };
  28. static const struct mtk_gate imp_iic_wrap_n_clks[] = {
  29. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_N_I2C0, "imp_iic_wrap_n_i2c0", "infra_i2c0", 0),
  30. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_N_I2C6, "imp_iic_wrap_n_i2c6", "infra_i2c0", 1),
  31. };
  32. static const struct mtk_gate imp_iic_wrap_s_clks[] = {
  33. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C7, "imp_iic_wrap_s_i2c7", "infra_i2c0", 0),
  34. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C8, "imp_iic_wrap_s_i2c8", "infra_i2c0", 1),
  35. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C9, "imp_iic_wrap_s_i2c9", "infra_i2c0", 2),
  36. };
  37. static const struct mtk_gate imp_iic_wrap_w_clks[] = {
  38. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_W_I2C5, "imp_iic_wrap_w_i2c5", "infra_i2c0", 0),
  39. };
  40. static const struct mtk_gate imp_iic_wrap_ws_clks[] = {
  41. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C1, "imp_iic_wrap_ws_i2c1", "infra_i2c0", 0),
  42. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C2, "imp_iic_wrap_ws_i2c2", "infra_i2c0", 1),
  43. GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C4, "imp_iic_wrap_ws_i2c4", "infra_i2c0", 2),
  44. };
  45. static const struct mtk_clk_desc imp_iic_wrap_c_desc = {
  46. .clks = imp_iic_wrap_c_clks,
  47. .num_clks = ARRAY_SIZE(imp_iic_wrap_c_clks),
  48. };
  49. static const struct mtk_clk_desc imp_iic_wrap_e_desc = {
  50. .clks = imp_iic_wrap_e_clks,
  51. .num_clks = ARRAY_SIZE(imp_iic_wrap_e_clks),
  52. };
  53. static const struct mtk_clk_desc imp_iic_wrap_n_desc = {
  54. .clks = imp_iic_wrap_n_clks,
  55. .num_clks = ARRAY_SIZE(imp_iic_wrap_n_clks),
  56. };
  57. static const struct mtk_clk_desc imp_iic_wrap_s_desc = {
  58. .clks = imp_iic_wrap_s_clks,
  59. .num_clks = ARRAY_SIZE(imp_iic_wrap_s_clks),
  60. };
  61. static const struct mtk_clk_desc imp_iic_wrap_w_desc = {
  62. .clks = imp_iic_wrap_w_clks,
  63. .num_clks = ARRAY_SIZE(imp_iic_wrap_w_clks),
  64. };
  65. static const struct mtk_clk_desc imp_iic_wrap_ws_desc = {
  66. .clks = imp_iic_wrap_ws_clks,
  67. .num_clks = ARRAY_SIZE(imp_iic_wrap_ws_clks),
  68. };
  69. static const struct of_device_id of_match_clk_mt8192_imp_iic_wrap[] = {
  70. {
  71. .compatible = "mediatek,mt8192-imp_iic_wrap_c",
  72. .data = &imp_iic_wrap_c_desc,
  73. }, {
  74. .compatible = "mediatek,mt8192-imp_iic_wrap_e",
  75. .data = &imp_iic_wrap_e_desc,
  76. }, {
  77. .compatible = "mediatek,mt8192-imp_iic_wrap_n",
  78. .data = &imp_iic_wrap_n_desc,
  79. }, {
  80. .compatible = "mediatek,mt8192-imp_iic_wrap_s",
  81. .data = &imp_iic_wrap_s_desc,
  82. }, {
  83. .compatible = "mediatek,mt8192-imp_iic_wrap_w",
  84. .data = &imp_iic_wrap_w_desc,
  85. }, {
  86. .compatible = "mediatek,mt8192-imp_iic_wrap_ws",
  87. .data = &imp_iic_wrap_ws_desc,
  88. }, {
  89. /* sentinel */
  90. }
  91. };
  92. static struct platform_driver clk_mt8192_imp_iic_wrap_drv = {
  93. .probe = mtk_clk_simple_probe,
  94. .remove = mtk_clk_simple_remove,
  95. .driver = {
  96. .name = "clk-mt8192-imp_iic_wrap",
  97. .of_match_table = of_match_clk_mt8192_imp_iic_wrap,
  98. },
  99. };
  100. builtin_platform_driver(clk_mt8192_imp_iic_wrap_drv);