Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

clk: mediatek: Add MT8196 ufssys clock support

Add support for the MT8196 ufssys clock controller, which provides clock
gate control for UFS.

Co-developed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Laura Nao <laura.nao@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Laura Nao and committed by
Stephen Boyd
a74d5e83 21277990

+116
+7
drivers/clk/mediatek/Kconfig
··· 1010 1010 help 1011 1011 This driver supports MediaTek MT8196 basic clocks. 1012 1012 1013 + config COMMON_CLK_MT8196_UFSSYS 1014 + tristate "Clock driver for MediaTek MT8196 ufssys" 1015 + depends on COMMON_CLK_MT8196 1016 + default COMMON_CLK_MT8196 1017 + help 1018 + This driver supports MediaTek MT8196 ufssys clocks. 1019 + 1013 1020 config COMMON_CLK_MT8365 1014 1021 tristate "Clock driver for MediaTek MT8365" 1015 1022 depends on ARCH_MEDIATEK || COMPILE_TEST
+1
drivers/clk/mediatek/Makefile
··· 153 153 obj-$(CONFIG_COMMON_CLK_MT8196) += clk-mt8196-apmixedsys.o clk-mt8196-topckgen.o \ 154 154 clk-mt8196-topckgen2.o clk-mt8196-vlpckgen.o \ 155 155 clk-mt8196-peri_ao.o 156 + obj-$(CONFIG_COMMON_CLK_MT8196_UFSSYS) += clk-mt8196-ufs_ao.o 156 157 obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o 157 158 obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o 158 159 obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o
+108
drivers/clk/mediatek/clk-mt8196-ufs_ao.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2025 MediaTek Inc. 4 + * Guangjie Song <guangjie.song@mediatek.com> 5 + * Copyright (c) 2025 Collabora Ltd. 6 + * Laura Nao <laura.nao@collabora.com> 7 + */ 8 + #include <dt-bindings/clock/mediatek,mt8196-clock.h> 9 + #include <dt-bindings/reset/mediatek,mt8196-resets.h> 10 + 11 + #include <linux/clk-provider.h> 12 + #include <linux/module.h> 13 + #include <linux/of_device.h> 14 + #include <linux/platform_device.h> 15 + 16 + #include "clk-gate.h" 17 + #include "clk-mtk.h" 18 + 19 + #define MT8196_UFSAO_RST0_SET_OFFSET 0x48 20 + #define MT8196_UFSAO_RST1_SET_OFFSET 0x148 21 + 22 + static const struct mtk_gate_regs ufsao0_cg_regs = { 23 + .set_ofs = 0x108, 24 + .clr_ofs = 0x10c, 25 + .sta_ofs = 0x104, 26 + }; 27 + 28 + static const struct mtk_gate_regs ufsao1_cg_regs = { 29 + .set_ofs = 0x8, 30 + .clr_ofs = 0xc, 31 + .sta_ofs = 0x4, 32 + }; 33 + 34 + #define GATE_UFSAO0(_id, _name, _parent, _shift) { \ 35 + .id = _id, \ 36 + .name = _name, \ 37 + .parent_name = _parent, \ 38 + .regs = &ufsao0_cg_regs, \ 39 + .shift = _shift, \ 40 + .ops = &mtk_clk_gate_ops_setclr, \ 41 + } 42 + 43 + #define GATE_UFSAO1(_id, _name, _parent, _shift) { \ 44 + .id = _id, \ 45 + .name = _name, \ 46 + .parent_name = _parent, \ 47 + .regs = &ufsao1_cg_regs, \ 48 + .shift = _shift, \ 49 + .ops = &mtk_clk_gate_ops_setclr, \ 50 + } 51 + 52 + static const struct mtk_gate ufsao_clks[] = { 53 + /* UFSAO0 */ 54 + GATE_UFSAO0(CLK_UFSAO_UFSHCI_UFS, "ufsao_ufshci_ufs", "ufs", 0), 55 + GATE_UFSAO0(CLK_UFSAO_UFSHCI_AES, "ufsao_ufshci_aes", "aes_ufsfde", 1), 56 + /* UFSAO1 */ 57 + GATE_UFSAO1(CLK_UFSAO_UNIPRO_TX_SYM, "ufsao_unipro_tx_sym", "clk26m", 0), 58 + GATE_UFSAO1(CLK_UFSAO_UNIPRO_RX_SYM0, "ufsao_unipro_rx_sym0", "clk26m", 1), 59 + GATE_UFSAO1(CLK_UFSAO_UNIPRO_RX_SYM1, "ufsao_unipro_rx_sym1", "clk26m", 2), 60 + GATE_UFSAO1(CLK_UFSAO_UNIPRO_SYS, "ufsao_unipro_sys", "ufs", 3), 61 + GATE_UFSAO1(CLK_UFSAO_UNIPRO_SAP, "ufsao_unipro_sap", "clk26m", 4), 62 + GATE_UFSAO1(CLK_UFSAO_PHY_SAP, "ufsao_phy_sap", "clk26m", 8), 63 + }; 64 + 65 + static u16 ufsao_rst_ofs[] = { 66 + MT8196_UFSAO_RST0_SET_OFFSET, 67 + MT8196_UFSAO_RST1_SET_OFFSET 68 + }; 69 + 70 + static u16 ufsao_rst_idx_map[] = { 71 + [MT8196_UFSAO_RST0_UFS_MPHY] = 8, 72 + [MT8196_UFSAO_RST1_UFS_UNIPRO] = 1 * RST_NR_PER_BANK + 0, 73 + [MT8196_UFSAO_RST1_UFS_CRYPTO] = 1 * RST_NR_PER_BANK + 1, 74 + [MT8196_UFSAO_RST1_UFSHCI] = 1 * RST_NR_PER_BANK + 2, 75 + }; 76 + 77 + static const struct mtk_clk_rst_desc ufsao_rst_desc = { 78 + .version = MTK_RST_SET_CLR, 79 + .rst_bank_ofs = ufsao_rst_ofs, 80 + .rst_bank_nr = ARRAY_SIZE(ufsao_rst_ofs), 81 + .rst_idx_map = ufsao_rst_idx_map, 82 + .rst_idx_map_nr = ARRAY_SIZE(ufsao_rst_idx_map), 83 + }; 84 + 85 + static const struct mtk_clk_desc ufsao_mcd = { 86 + .clks = ufsao_clks, 87 + .num_clks = ARRAY_SIZE(ufsao_clks), 88 + .rst_desc = &ufsao_rst_desc, 89 + }; 90 + 91 + static const struct of_device_id of_match_clk_mt8196_ufs_ao[] = { 92 + { .compatible = "mediatek,mt8196-ufscfg-ao", .data = &ufsao_mcd }, 93 + { /* sentinel */ } 94 + }; 95 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8196_ufs_ao); 96 + 97 + static struct platform_driver clk_mt8196_ufs_ao_drv = { 98 + .probe = mtk_clk_simple_probe, 99 + .remove = mtk_clk_simple_remove, 100 + .driver = { 101 + .name = "clk-mt8196-ufs-ao", 102 + .of_match_table = of_match_clk_mt8196_ufs_ao, 103 + }, 104 + }; 105 + 106 + module_platform_driver(clk_mt8196_ufs_ao_drv); 107 + MODULE_DESCRIPTION("MediaTek MT8196 ufs_ao clocks driver"); 108 + MODULE_LICENSE("GPL");