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