162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2014 MediaTek Inc. 462306a36Sopenharmony_ci * Author: Shunli Wang <shunli.wang@mediatek.com> 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/clk-provider.h> 862306a36Sopenharmony_ci#include <linux/platform_device.h> 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include "clk-mtk.h" 1162306a36Sopenharmony_ci#include "clk-gate.h" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <dt-bindings/clock/mt2701-clk.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_cistatic const struct mtk_gate_regs bdp0_cg_regs = { 1662306a36Sopenharmony_ci .set_ofs = 0x0104, 1762306a36Sopenharmony_ci .clr_ofs = 0x0108, 1862306a36Sopenharmony_ci .sta_ofs = 0x0100, 1962306a36Sopenharmony_ci}; 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_cistatic const struct mtk_gate_regs bdp1_cg_regs = { 2262306a36Sopenharmony_ci .set_ofs = 0x0114, 2362306a36Sopenharmony_ci .clr_ofs = 0x0118, 2462306a36Sopenharmony_ci .sta_ofs = 0x0110, 2562306a36Sopenharmony_ci}; 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define GATE_BDP0(_id, _name, _parent, _shift) \ 2862306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &bdp0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define GATE_BDP1(_id, _name, _parent, _shift) \ 3162306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &bdp1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_cistatic const struct mtk_gate bdp_clks[] = { 3462306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_BRG_BA, "brg_baclk", "mm_sel", 0), 3562306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_BRG_DRAM, "brg_dram", "mm_sel", 1), 3662306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_LARB_DRAM, "larb_dram", "mm_sel", 2), 3762306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_WR_VDI_PXL, "wr_vdi_pxl", "hdmi_0_deep340m", 3), 3862306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_WR_VDI_DRAM, "wr_vdi_dram", "mm_sel", 4), 3962306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_WR_B, "wr_bclk", "mm_sel", 5), 4062306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_DGI_IN, "dgi_in", "dpi1_sel", 6), 4162306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_DGI_OUT, "dgi_out", "dpi1_sel", 7), 4262306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_FMT_MAST_27, "fmt_mast_27", "dpi1_sel", 8), 4362306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_FMT_B, "fmt_bclk", "mm_sel", 9), 4462306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_OSD_B, "osd_bclk", "mm_sel", 10), 4562306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_OSD_DRAM, "osd_dram", "mm_sel", 11), 4662306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_OSD_AGENT, "osd_agent", "osd_sel", 12), 4762306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_OSD_PXL, "osd_pxl", "dpi1_sel", 13), 4862306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_RLE_B, "rle_bclk", "mm_sel", 14), 4962306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_RLE_AGENT, "rle_agent", "mm_sel", 15), 5062306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_RLE_DRAM, "rle_dram", "mm_sel", 16), 5162306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_F27M, "f27m", "di_sel", 17), 5262306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_F27M_VDOUT, "f27m_vdout", "di_sel", 18), 5362306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_F27_74_74, "f27_74_74", "di_sel", 19), 5462306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_F2FS, "f2fs", "di_sel", 20), 5562306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_F2FS74_148, "f2fs74_148", "di_sel", 21), 5662306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_FB, "fbclk", "mm_sel", 22), 5762306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_VDO_DRAM, "vdo_dram", "mm_sel", 23), 5862306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_VDO_2FS, "vdo_2fs", "di_sel", 24), 5962306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_VDO_B, "vdo_bclk", "mm_sel", 25), 6062306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_WR_DI_PXL, "wr_di_pxl", "di_sel", 26), 6162306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_WR_DI_DRAM, "wr_di_dram", "mm_sel", 27), 6262306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_WR_DI_B, "wr_di_bclk", "mm_sel", 28), 6362306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_NR_PXL, "nr_pxl", "nr_sel", 29), 6462306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_NR_DRAM, "nr_dram", "mm_sel", 30), 6562306a36Sopenharmony_ci GATE_BDP0(CLK_BDP_NR_B, "nr_bclk", "mm_sel", 31), 6662306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_F, "rx_fclk", "hadds2_fbclk", 0), 6762306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_X, "rx_xclk", "clk26m", 1), 6862306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RXPDT, "rxpdtclk", "hdmi_0_pix340m", 2), 6962306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_CSCL_N, "rx_cscl_n", "clk26m", 3), 7062306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_CSCL, "rx_cscl", "clk26m", 4), 7162306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_DDCSCL_N, "rx_ddcscl_n", "hdmi_scl_rx", 5), 7262306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_DDCSCL, "rx_ddcscl", "hdmi_scl_rx", 6), 7362306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_VCO, "rx_vcoclk", "hadds2pll_294m", 7), 7462306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_DP, "rx_dpclk", "hdmi_0_pll340m", 8), 7562306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_P, "rx_pclk", "hdmi_0_pll340m", 9), 7662306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_M, "rx_mclk", "hadds2pll_294m", 10), 7762306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_RX_PLL, "rx_pllclk", "hdmi_0_pix340m", 11), 7862306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_BRG_RT_B, "brg_rt_bclk", "mm_sel", 12), 7962306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_BRG_RT_DRAM, "brg_rt_dram", "mm_sel", 13), 8062306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_LARBRT_DRAM, "larbrt_dram", "mm_sel", 14), 8162306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_TMDS_SYN, "tmds_syn", "hdmi_0_pll340m", 15), 8262306a36Sopenharmony_ci GATE_BDP1(CLK_BDP_HDMI_MON, "hdmi_mon", "hdmi_0_pll340m", 16), 8362306a36Sopenharmony_ci}; 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_cistatic const struct mtk_clk_desc bdp_desc = { 8662306a36Sopenharmony_ci .clks = bdp_clks, 8762306a36Sopenharmony_ci .num_clks = ARRAY_SIZE(bdp_clks), 8862306a36Sopenharmony_ci}; 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_cistatic const struct of_device_id of_match_clk_mt2701_bdp[] = { 9162306a36Sopenharmony_ci { 9262306a36Sopenharmony_ci .compatible = "mediatek,mt2701-bdpsys", 9362306a36Sopenharmony_ci .data = &bdp_desc, 9462306a36Sopenharmony_ci }, { 9562306a36Sopenharmony_ci /* sentinel */ 9662306a36Sopenharmony_ci } 9762306a36Sopenharmony_ci}; 9862306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_match_clk_mt2701_bdp); 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_cistatic struct platform_driver clk_mt2701_bdp_drv = { 10162306a36Sopenharmony_ci .probe = mtk_clk_simple_probe, 10262306a36Sopenharmony_ci .remove_new = mtk_clk_simple_remove, 10362306a36Sopenharmony_ci .driver = { 10462306a36Sopenharmony_ci .name = "clk-mt2701-bdp", 10562306a36Sopenharmony_ci .of_match_table = of_match_clk_mt2701_bdp, 10662306a36Sopenharmony_ci }, 10762306a36Sopenharmony_ci}; 10862306a36Sopenharmony_cimodule_platform_driver(clk_mt2701_bdp_drv); 10962306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 110