clk-mt8167-vdec.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2020 MediaTek Inc.
  4. * Copyright (c) 2020 BayLibre, SAS
  5. * Author: James Liao <[email protected]>
  6. * Fabien Parent <[email protected]>
  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. GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
  28. #define GATE_VDEC1_I(_id, _name, _parent, _shift) \
  29. GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
  30. static const struct mtk_gate vdec_clks[] __initconst = {
  31. /* VDEC0 */
  32. GATE_VDEC0_I(CLK_VDEC_CKEN, "vdec_cken", "rg_vdec", 0),
  33. /* VDEC1 */
  34. GATE_VDEC1_I(CLK_VDEC_LARB1_CKEN, "vdec_larb1_cken", "smi_mm", 0),
  35. };
  36. static void __init mtk_vdecsys_init(struct device_node *node)
  37. {
  38. struct clk_hw_onecell_data *clk_data;
  39. int r;
  40. clk_data = mtk_alloc_clk_data(CLK_VDEC_NR_CLK);
  41. mtk_clk_register_gates(node, vdec_clks, ARRAY_SIZE(vdec_clks), clk_data);
  42. r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
  43. if (r)
  44. pr_err("%s(): could not register clock provider: %d\n",
  45. __func__, r);
  46. }
  47. CLK_OF_DECLARE(mtk_vdecsys, "mediatek,mt8167-vdecsys", mtk_vdecsys_init);