18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2014 MediaTek Inc. 48c2ecf20Sopenharmony_ci * Author: Shunli Wang <shunli.wang@mediatek.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 88c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include "clk-mtk.h" 118c2ecf20Sopenharmony_ci#include "clk-gate.h" 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <dt-bindings/clock/mt2701-clk.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistatic const struct mtk_gate_regs eth_cg_regs = { 168c2ecf20Sopenharmony_ci .sta_ofs = 0x0030, 178c2ecf20Sopenharmony_ci}; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define GATE_ETH(_id, _name, _parent, _shift) { \ 208c2ecf20Sopenharmony_ci .id = _id, \ 218c2ecf20Sopenharmony_ci .name = _name, \ 228c2ecf20Sopenharmony_ci .parent_name = _parent, \ 238c2ecf20Sopenharmony_ci .regs = ð_cg_regs, \ 248c2ecf20Sopenharmony_ci .shift = _shift, \ 258c2ecf20Sopenharmony_ci .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 268c2ecf20Sopenharmony_ci } 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistatic const struct mtk_gate eth_clks[] = { 298c2ecf20Sopenharmony_ci GATE_ETH(CLK_ETHSYS_HSDMA, "hsdma_clk", "ethif_sel", 5), 308c2ecf20Sopenharmony_ci GATE_ETH(CLK_ETHSYS_ESW, "esw_clk", "ethpll_500m_ck", 6), 318c2ecf20Sopenharmony_ci GATE_ETH(CLK_ETHSYS_GP2, "gp2_clk", "trgpll", 7), 328c2ecf20Sopenharmony_ci GATE_ETH(CLK_ETHSYS_GP1, "gp1_clk", "ethpll_500m_ck", 8), 338c2ecf20Sopenharmony_ci GATE_ETH(CLK_ETHSYS_PCM, "pcm_clk", "ethif_sel", 11), 348c2ecf20Sopenharmony_ci GATE_ETH(CLK_ETHSYS_GDMA, "gdma_clk", "ethif_sel", 14), 358c2ecf20Sopenharmony_ci GATE_ETH(CLK_ETHSYS_I2S, "i2s_clk", "ethif_sel", 17), 368c2ecf20Sopenharmony_ci GATE_ETH(CLK_ETHSYS_CRYPTO, "crypto_clk", "ethif_sel", 29), 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistatic const struct of_device_id of_match_clk_mt2701_eth[] = { 408c2ecf20Sopenharmony_ci { .compatible = "mediatek,mt2701-ethsys", }, 418c2ecf20Sopenharmony_ci {} 428c2ecf20Sopenharmony_ci}; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistatic int clk_mt2701_eth_probe(struct platform_device *pdev) 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci struct clk_onecell_data *clk_data; 478c2ecf20Sopenharmony_ci int r; 488c2ecf20Sopenharmony_ci struct device_node *node = pdev->dev.of_node; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci clk_data = mtk_alloc_clk_data(CLK_ETHSYS_NR); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci mtk_clk_register_gates(node, eth_clks, ARRAY_SIZE(eth_clks), 538c2ecf20Sopenharmony_ci clk_data); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 568c2ecf20Sopenharmony_ci if (r) 578c2ecf20Sopenharmony_ci dev_err(&pdev->dev, 588c2ecf20Sopenharmony_ci "could not register clock provider: %s: %d\n", 598c2ecf20Sopenharmony_ci pdev->name, r); 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci mtk_register_reset_controller(node, 1, 0x34); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci return r; 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistatic struct platform_driver clk_mt2701_eth_drv = { 678c2ecf20Sopenharmony_ci .probe = clk_mt2701_eth_probe, 688c2ecf20Sopenharmony_ci .driver = { 698c2ecf20Sopenharmony_ci .name = "clk-mt2701-eth", 708c2ecf20Sopenharmony_ci .of_match_table = of_match_clk_mt2701_eth, 718c2ecf20Sopenharmony_ci }, 728c2ecf20Sopenharmony_ci}; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cibuiltin_platform_driver(clk_mt2701_eth_drv); 75