clk-mt6735-vdecsys.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2022 Yassine Oudjana <y.oudjana@protonmail.com>
  4. */
  5. #include <linux/clk-provider.h>
  6. #include <linux/platform_device.h>
  7. #include "clk-gate.h"
  8. #include "clk-mtk.h"
  9. #include <dt-bindings/clock/mediatek,mt6735-vdecsys.h>
  10. #include <dt-bindings/reset/mediatek,mt6735-vdecsys.h>
  11. #define VDEC_CKEN_SET 0x00
  12. #define VDEC_CKEN_CLR 0x04
  13. #define SMI_LARB1_CKEN_SET 0x08
  14. #define SMI_LARB1_CKEN_CLR 0x0c
  15. #define VDEC_RESETB_CON 0x10
  16. #define SMI_LARB1_RESETB_CON 0x14
  17. #define RST_NR_PER_BANK 32
  18. static struct mtk_gate_regs vdec_cg_regs = {
  19. .set_ofs = VDEC_CKEN_SET,
  20. .clr_ofs = VDEC_CKEN_CLR,
  21. .sta_ofs = VDEC_CKEN_SET,
  22. };
  23. static struct mtk_gate_regs smi_larb1_cg_regs = {
  24. .set_ofs = SMI_LARB1_CKEN_SET,
  25. .clr_ofs = SMI_LARB1_CKEN_CLR,
  26. .sta_ofs = SMI_LARB1_CKEN_SET,
  27. };
  28. static const struct mtk_gate vdecsys_gates[] = {
  29. GATE_MTK(CLK_VDEC_VDEC, "vdec", "vdec_sel", &vdec_cg_regs, 0, &mtk_clk_gate_ops_setclr_inv),
  30. GATE_MTK(CLK_VDEC_SMI_LARB1, "smi_larb1", "vdec_sel", &smi_larb1_cg_regs, 0, &mtk_clk_gate_ops_setclr_inv),
  31. };
  32. static u16 vdecsys_rst_bank_ofs[] = { VDEC_RESETB_CON, SMI_LARB1_RESETB_CON };
  33. static u16 vdecsys_rst_idx_map[] = {
  34. [MT6735_VDEC_RST0_VDEC] = 0 * RST_NR_PER_BANK + 0,
  35. [MT6735_VDEC_RST1_SMI_LARB1] = 1 * RST_NR_PER_BANK + 0,
  36. };
  37. static const struct mtk_clk_rst_desc vdecsys_resets = {
  38. .version = MTK_RST_SIMPLE,
  39. .rst_bank_ofs = vdecsys_rst_bank_ofs,
  40. .rst_bank_nr = ARRAY_SIZE(vdecsys_rst_bank_ofs),
  41. .rst_idx_map = vdecsys_rst_idx_map,
  42. .rst_idx_map_nr = ARRAY_SIZE(vdecsys_rst_idx_map)
  43. };
  44. static const struct mtk_clk_desc vdecsys_clks = {
  45. .clks = vdecsys_gates,
  46. .num_clks = ARRAY_SIZE(vdecsys_gates),
  47. .rst_desc = &vdecsys_resets
  48. };
  49. static const struct of_device_id of_match_mt6735_vdecsys[] = {
  50. { .compatible = "mediatek,mt6735-vdecsys", .data = &vdecsys_clks },
  51. { /* sentinel */ }
  52. };
  53. static struct platform_driver clk_mt6735_vdecsys = {
  54. .probe = mtk_clk_simple_probe,
  55. .remove = mtk_clk_simple_remove,
  56. .driver = {
  57. .name = "clk-mt6735-vdecsys",
  58. .of_match_table = of_match_mt6735_vdecsys,
  59. },
  60. };
  61. module_platform_driver(clk_mt6735_vdecsys);
  62. MODULE_AUTHOR("Yassine Oudjana <y.oudjana@protonmail.com>");
  63. MODULE_DESCRIPTION("MediaTek MT6735 vdecsys clock and reset driver");
  64. MODULE_LICENSE("GPL");