clk-mt8167-vdec.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2020 MediaTek Inc.
  4. * Copyright (c) 2020 BayLibre, SAS
  5. * Author: James Liao <jamesjj.liao@mediatek.com>
  6. * Fabien Parent <fparent@baylibre.com>
  7. */
  8. #include <linux/clk-provider.h>
  9. #include <linux/of.h>
  10. #include <linux/of_address.h>
  11. #include <linux/of_device.h>
  12. #include <linux/platform_device.h>
  13. #include "clk-mtk.h"
  14. #include "clk-gate.h"
  15. #include <dt-bindings/clock/mt8167-clk.h>
  16. static const struct mtk_gate_regs vdec0_cg_regs = {
  17. .set_ofs = 0x0,
  18. .clr_ofs = 0x4,
  19. .sta_ofs = 0x0,
  20. };
  21. static const struct mtk_gate_regs vdec1_cg_regs = {
  22. .set_ofs = 0x8,
  23. .clr_ofs = 0xc,
  24. .sta_ofs = 0x8,
  25. };
  26. #define GATE_VDEC0_I(_id, _name, _parent, _shift) { \
  27. .id = _id, \
  28. .name = _name, \
  29. .parent_name = _parent, \
  30. .regs = &vdec0_cg_regs, \
  31. .shift = _shift, \
  32. .ops = &mtk_clk_gate_ops_setclr_inv, \
  33. }
  34. #define GATE_VDEC1_I(_id, _name, _parent, _shift) { \
  35. .id = _id, \
  36. .name = _name, \
  37. .parent_name = _parent, \
  38. .regs = &vdec1_cg_regs, \
  39. .shift = _shift, \
  40. .ops = &mtk_clk_gate_ops_setclr_inv, \
  41. }
  42. static const struct mtk_gate vdec_clks[] __initconst = {
  43. /* VDEC0 */
  44. GATE_VDEC0_I(CLK_VDEC_CKEN, "vdec_cken", "rg_vdec", 0),
  45. /* VDEC1 */
  46. GATE_VDEC1_I(CLK_VDEC_LARB1_CKEN, "vdec_larb1_cken", "smi_mm", 0),
  47. };
  48. static void __init mtk_vdecsys_init(struct device_node *node)
  49. {
  50. struct clk_onecell_data *clk_data;
  51. int r;
  52. clk_data = mtk_alloc_clk_data(CLK_VDEC_NR_CLK);
  53. mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_clks), clk_data);
  54. r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
  55. if (r)
  56. pr_err("%s(): could not register clock provider: %d\n",
  57. __func__, r);
  58. }
  59. CLK_OF_DECLARE(mtk_vdecsys, "mediatek,mt8167-vdecsys", mtk_vdecsys_init);